Allow a displayName to be passed when creating admin user (#13516)
* Allow a displayName to be passed when creating admin user * Set the first and last names * Don't format handlebars files on save * Use familyName and givenName
This commit is contained in:
parent
12edb9c001
commit
6bdc726d55
|
@ -24,5 +24,8 @@
|
|||
},
|
||||
"[svelte]": {
|
||||
"editor.defaultFormatter": "svelte.svelte-vscode"
|
||||
},
|
||||
"[handlebars]": {
|
||||
"editor.formatOnSave": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ type CreateAdminUserOpts = {
|
|||
hashPassword?: boolean
|
||||
requirePassword?: boolean
|
||||
skipPasswordValidation?: boolean
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
}
|
||||
type FeatureFns = { isSSOEnforced: FeatureFn; isAppBuildersEnabled: FeatureFn }
|
||||
|
||||
|
@ -517,6 +519,8 @@ export class UserDB {
|
|||
global: true,
|
||||
},
|
||||
tenantId,
|
||||
firstName: opts?.firstName,
|
||||
lastName: opts?.lastName,
|
||||
}
|
||||
if (opts?.ssoId) {
|
||||
user.ssoId = opts.ssoId
|
||||
|
|
|
@ -66,6 +66,8 @@ export interface CreateAdminUserRequest {
|
|||
password?: string
|
||||
tenantId: string
|
||||
ssoId?: string
|
||||
familyName?: string
|
||||
givenName?: string
|
||||
}
|
||||
|
||||
export interface AddSSoUserRequest {
|
||||
|
|
|
@ -22,6 +22,13 @@ export interface UserSSO {
|
|||
providerType: SSOProviderType
|
||||
oauth2?: OAuth2
|
||||
thirdPartyProfile?: SSOProfileJson
|
||||
profile?: {
|
||||
displayName?: string
|
||||
name?: {
|
||||
givenName?: string
|
||||
familyName?: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type SSOUser = User & UserSSO
|
||||
|
|
|
@ -116,7 +116,8 @@ const parseBooleanParam = (param: any) => {
|
|||
export const adminUser = async (
|
||||
ctx: Ctx<CreateAdminUserRequest, CreateAdminUserResponse>
|
||||
) => {
|
||||
const { email, password, tenantId, ssoId } = ctx.request.body
|
||||
const { email, password, tenantId, ssoId, givenName, familyName } =
|
||||
ctx.request.body
|
||||
|
||||
if (await platform.tenants.exists(tenantId)) {
|
||||
ctx.throw(403, "Organisation already exists.")
|
||||
|
@ -151,6 +152,8 @@ export const adminUser = async (
|
|||
ssoId,
|
||||
hashPassword,
|
||||
requirePassword,
|
||||
firstName: givenName,
|
||||
lastName: familyName,
|
||||
})
|
||||
|
||||
// events
|
||||
|
|
|
@ -16,6 +16,8 @@ function buildAdminInitValidation() {
|
|||
password: OPTIONAL_STRING,
|
||||
tenantId: Joi.string().required(),
|
||||
ssoId: Joi.string(),
|
||||
familyName: OPTIONAL_STRING,
|
||||
givenName: OPTIONAL_STRING,
|
||||
})
|
||||
.required()
|
||||
.unknown(false)
|
||||
|
|
Loading…
Reference in New Issue