1
0
Fork 0
mirror of synced 2024-05-18 03:12:48 +12:00

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:
melohagan 2024-04-18 13:52:00 +01:00 committed by GitHub
parent 12edb9c001
commit 6bdc726d55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 22 additions and 1 deletions

View file

@ -24,5 +24,8 @@
},
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"[handlebars]": {
"editor.formatOnSave": false
}
}

View file

@ -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

View file

@ -66,6 +66,8 @@ export interface CreateAdminUserRequest {
password?: string
tenantId: string
ssoId?: string
familyName?: string
givenName?: string
}
export interface AddSSoUserRequest {

View file

@ -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

View file

@ -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

View file

@ -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)