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 <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Tana Berry <tana@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		@ -17,6 +17,10 @@ import { CoreApi, User } from "@goauthentik/api";
 | 
			
		||||
 | 
			
		||||
@customElement("ak-user-form")
 | 
			
		||||
export class UserForm extends ModelForm<User, number> {
 | 
			
		||||
    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<User, number> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async send(data: User): Promise<User> {
 | 
			
		||||
        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<User, number> {
 | 
			
		||||
            </ak-form-element-horizontal>
 | 
			
		||||
            <ak-form-element-horizontal
 | 
			
		||||
                label=${msg("Attributes")}
 | 
			
		||||
                ?required=${true}
 | 
			
		||||
                ?required=${false}
 | 
			
		||||
                name="attributes"
 | 
			
		||||
            >
 | 
			
		||||
                <ak-codemirror
 | 
			
		||||
                    mode="yaml"
 | 
			
		||||
                    value="${YAML.stringify(first(this.instance?.attributes, {}))}"
 | 
			
		||||
                    value="${YAML.stringify(
 | 
			
		||||
                        first(this.instance?.attributes, UserForm.defaultUserAttributes),
 | 
			
		||||
                    )}"
 | 
			
		||||
                >
 | 
			
		||||
                </ak-codemirror>
 | 
			
		||||
                <p class="pf-c-form__helper-text">
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user