web/user: fix race condition in user settings flow executor (#13163) Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens L. <jens@goauthentik.io>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							8a23eaef1e
						
					
				
				
					commit
					cd6d0a47f3
				
			@ -3,6 +3,7 @@ import type { AbstractConstructor } from "@goauthentik/elements/types.js";
 | 
			
		||||
 | 
			
		||||
import { consume } from "@lit/context";
 | 
			
		||||
import type { LitElement } from "lit";
 | 
			
		||||
import { state } from "lit/decorators.js";
 | 
			
		||||
 | 
			
		||||
import type { CurrentBrand } from "@goauthentik/api";
 | 
			
		||||
 | 
			
		||||
@ -12,6 +13,7 @@ export function WithBrandConfig<T extends AbstractConstructor<LitElement>>(
 | 
			
		||||
) {
 | 
			
		||||
    abstract class WithBrandProvider extends superclass {
 | 
			
		||||
        @consume({ context: authentikBrandContext, subscribe })
 | 
			
		||||
        @state()
 | 
			
		||||
        public brand!: CurrentBrand;
 | 
			
		||||
    }
 | 
			
		||||
    return WithBrandProvider;
 | 
			
		||||
 | 
			
		||||
@ -10,7 +10,7 @@ import { StageHost } from "@goauthentik/flow/stages/base";
 | 
			
		||||
import "@goauthentik/user/user-settings/details/stages/prompt/PromptStage";
 | 
			
		||||
 | 
			
		||||
import { msg } from "@lit/localize";
 | 
			
		||||
import { CSSResult, TemplateResult, html } from "lit";
 | 
			
		||||
import { CSSResult, PropertyValues, TemplateResult, html } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators.js";
 | 
			
		||||
import { unsafeHTML } from "lit/directives/unsafe-html.js";
 | 
			
		||||
 | 
			
		||||
@ -83,12 +83,14 @@ export class UserSettingsFlowExecutor
 | 
			
		||||
            });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    firstUpdated(): void {
 | 
			
		||||
        this.flowSlug = this.brand?.flowUserSettings;
 | 
			
		||||
        if (!this.flowSlug) {
 | 
			
		||||
            return;
 | 
			
		||||
    updated(changedProperties: PropertyValues<this>): void {
 | 
			
		||||
        if (changedProperties.has("brand") && this.brand) {
 | 
			
		||||
            this.flowSlug = this.brand?.flowUserSettings;
 | 
			
		||||
            if (!this.flowSlug) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            this.nextChallenge();
 | 
			
		||||
        }
 | 
			
		||||
        this.nextChallenge();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async nextChallenge(): Promise<void> {
 | 
			
		||||
@ -161,7 +163,7 @@ export class UserSettingsFlowExecutor
 | 
			
		||||
                // Flow has finished, so let's load while in the background we can restart the flow
 | 
			
		||||
                this.loading = true;
 | 
			
		||||
                console.debug("authentik/user/flows: redirect to '/', restarting flow.");
 | 
			
		||||
                this.firstUpdated();
 | 
			
		||||
                this.nextChallenge();
 | 
			
		||||
                this.globalRefresh();
 | 
			
		||||
                showMessage({
 | 
			
		||||
                    level: MessageLevel.success,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user