Review feedback
This commit is contained in:
parent
ab45e06edb
commit
f622c84ebc
|
@ -1,11 +1,3 @@
|
|||
export interface UpdateSelf {
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
password?: string
|
||||
forceResetPassword?: boolean
|
||||
onboardedAt?: string
|
||||
}
|
||||
|
||||
export interface SaveUserOpts {
|
||||
hashPassword?: boolean
|
||||
requirePassword?: boolean
|
||||
|
|
|
@ -10,12 +10,7 @@ import {
|
|||
} from "@budibase/backend-core"
|
||||
import env from "../../../environment"
|
||||
import { groups } from "@budibase/pro"
|
||||
import {
|
||||
UpdateSelfRequest,
|
||||
UpdateSelfResponse,
|
||||
UpdateSelf,
|
||||
UserCtx,
|
||||
} from "@budibase/types"
|
||||
import { UpdateSelfRequest, UpdateSelfResponse, UserCtx } from "@budibase/types"
|
||||
const { getCookie, clearCookie, newid } = utils
|
||||
|
||||
function newTestApiKey() {
|
||||
|
@ -122,13 +117,14 @@ export async function getSelf(ctx: any) {
|
|||
export async function updateSelf(
|
||||
ctx: UserCtx<UpdateSelfRequest, UpdateSelfResponse>
|
||||
) {
|
||||
const body = ctx.request.body
|
||||
const update = ctx.request.body
|
||||
|
||||
const update: UpdateSelf = {
|
||||
...body,
|
||||
let user = await userSdk.getUser(ctx.user._id!)
|
||||
user = {
|
||||
...user,
|
||||
...update,
|
||||
}
|
||||
|
||||
const user = await userSdk.updateSelf(ctx.user._id!, update)
|
||||
user = await userSdk.save(user, { requirePassword: false })
|
||||
|
||||
if (update.password) {
|
||||
// Log all other sessions out apart from the current one
|
||||
|
|
|
@ -29,7 +29,6 @@ import {
|
|||
PlatformUserByEmail,
|
||||
RowResponse,
|
||||
SearchUsersRequest,
|
||||
UpdateSelf,
|
||||
User,
|
||||
SaveUserOpts,
|
||||
} from "@budibase/types"
|
||||
|
@ -227,15 +226,6 @@ export async function isPreventPasswordActions(user: User) {
|
|||
return !!(account && isSSOAccount(account))
|
||||
}
|
||||
|
||||
export async function updateSelf(id: string, data: UpdateSelf) {
|
||||
let user = await getUser(id)
|
||||
user = {
|
||||
...user,
|
||||
...data,
|
||||
}
|
||||
return save(user, { requirePassword: false })
|
||||
}
|
||||
|
||||
export const save = async (
|
||||
user: User,
|
||||
opts: SaveUserOpts = {}
|
||||
|
|
Loading…
Reference in New Issue