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 { consume } from "@lit/context";
 | 
				
			||||||
import type { LitElement } from "lit";
 | 
					import type { LitElement } from "lit";
 | 
				
			||||||
 | 
					import { state } from "lit/decorators.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import type { CurrentBrand } from "@goauthentik/api";
 | 
					import type { CurrentBrand } from "@goauthentik/api";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -12,6 +13,7 @@ export function WithBrandConfig<T extends AbstractConstructor<LitElement>>(
 | 
				
			|||||||
) {
 | 
					) {
 | 
				
			||||||
    abstract class WithBrandProvider extends superclass {
 | 
					    abstract class WithBrandProvider extends superclass {
 | 
				
			||||||
        @consume({ context: authentikBrandContext, subscribe })
 | 
					        @consume({ context: authentikBrandContext, subscribe })
 | 
				
			||||||
 | 
					        @state()
 | 
				
			||||||
        public brand!: CurrentBrand;
 | 
					        public brand!: CurrentBrand;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return WithBrandProvider;
 | 
					    return WithBrandProvider;
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ import { StageHost } from "@goauthentik/flow/stages/base";
 | 
				
			|||||||
import "@goauthentik/user/user-settings/details/stages/prompt/PromptStage";
 | 
					import "@goauthentik/user/user-settings/details/stages/prompt/PromptStage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { msg } from "@lit/localize";
 | 
					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 { customElement, property } from "lit/decorators.js";
 | 
				
			||||||
import { unsafeHTML } from "lit/directives/unsafe-html.js";
 | 
					import { unsafeHTML } from "lit/directives/unsafe-html.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -83,12 +83,14 @@ export class UserSettingsFlowExecutor
 | 
				
			|||||||
            });
 | 
					            });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    firstUpdated(): void {
 | 
					    updated(changedProperties: PropertyValues<this>): void {
 | 
				
			||||||
        this.flowSlug = this.brand?.flowUserSettings;
 | 
					        if (changedProperties.has("brand") && this.brand) {
 | 
				
			||||||
        if (!this.flowSlug) {
 | 
					            this.flowSlug = this.brand?.flowUserSettings;
 | 
				
			||||||
            return;
 | 
					            if (!this.flowSlug) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            this.nextChallenge();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.nextChallenge();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async nextChallenge(): Promise<void> {
 | 
					    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
 | 
					                // Flow has finished, so let's load while in the background we can restart the flow
 | 
				
			||||||
                this.loading = true;
 | 
					                this.loading = true;
 | 
				
			||||||
                console.debug("authentik/user/flows: redirect to '/', restarting flow.");
 | 
					                console.debug("authentik/user/flows: redirect to '/', restarting flow.");
 | 
				
			||||||
                this.firstUpdated();
 | 
					                this.nextChallenge();
 | 
				
			||||||
                this.globalRefresh();
 | 
					                this.globalRefresh();
 | 
				
			||||||
                showMessage({
 | 
					                showMessage({
 | 
				
			||||||
                    level: MessageLevel.success,
 | 
					                    level: MessageLevel.success,
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user