From b7faecea126168a00f85b85ecccc6055f284d65c Mon Sep 17 00:00:00 2001 From: Tana M Berry Date: Sat, 26 Aug 2023 14:13:39 -0500 Subject: [PATCH] web/admin: set required flag to false for user attributes (#6418) * sert required flag to false for user attributes * fallback for null value Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer Co-authored-by: Tana Berry Co-authored-by: Jens Langhammer --- web/src/admin/users/UserForm.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/web/src/admin/users/UserForm.ts b/web/src/admin/users/UserForm.ts index c46b205c1..b2cdef833 100644 --- a/web/src/admin/users/UserForm.ts +++ b/web/src/admin/users/UserForm.ts @@ -17,6 +17,10 @@ import { CoreApi, User } from "@goauthentik/api"; @customElement("ak-user-form") export class UserForm extends ModelForm { + static get defaultUserAttributes(): { [key: string]: unknown } { + return {}; + } + static get styles(): CSSResult[] { return super.styles.concat(css` .pf-c-button.pf-m-control { @@ -43,6 +47,9 @@ export class UserForm extends ModelForm { } async send(data: User): Promise { + if (data.attributes === null) { + data.attributes = UserForm.defaultUserAttributes; + } if (this.instance?.pk) { return new CoreApi(DEFAULT_CONFIG).coreUsersPartialUpdate({ id: this.instance.pk, @@ -145,12 +152,14 @@ export class UserForm extends ModelForm {