web/flow: fix deep redirects not working properly
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
a1f961db97
commit
37655e1e21
|
@ -127,14 +127,6 @@ export class FlowExecutor extends LitElement implements StageHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated(): void {
|
firstUpdated(): void {
|
||||||
// Check if there is a ?next arg and save it
|
|
||||||
// this is used for deep linking, if a user tries to access an application,
|
|
||||||
// but needs to authenticate first
|
|
||||||
const queryVars = getQueryVariables();
|
|
||||||
if (NEXT_ARG in queryVars) {
|
|
||||||
const next = queryVars[NEXT_ARG];
|
|
||||||
localStorage.setItem(NEXT_ARG, next);
|
|
||||||
}
|
|
||||||
new RootApi(DEFAULT_CONFIG).rootConfigList().then((config) => {
|
new RootApi(DEFAULT_CONFIG).rootConfigList().then((config) => {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
});
|
});
|
||||||
|
@ -175,19 +167,29 @@ export class FlowExecutor extends LitElement implements StageHost {
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private redirect(challenge: RedirectChallenge): void {
|
||||||
|
// Check if there is a ?next arg and save it
|
||||||
|
// this is used for deep linking, if a user tries to access an application,
|
||||||
|
// but needs to authenticate first
|
||||||
|
const queryVars = getQueryVariables();
|
||||||
|
localStorage.clear();
|
||||||
|
if (NEXT_ARG in queryVars) {
|
||||||
|
const next = queryVars[NEXT_ARG];
|
||||||
|
console.debug("authentik/flows: redirecting to saved url", next);
|
||||||
|
window.location.assign(next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.debug("authentik/flows: redirecting to url from server", challenge.to);
|
||||||
|
window.location.assign(challenge.to);
|
||||||
|
}
|
||||||
|
|
||||||
renderChallenge(): TemplateResult {
|
renderChallenge(): TemplateResult {
|
||||||
if (!this.challenge) {
|
if (!this.challenge) {
|
||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
switch (this.challenge.type) {
|
switch (this.challenge.type) {
|
||||||
case ChallengeTypeEnum.Redirect:
|
case ChallengeTypeEnum.Redirect:
|
||||||
console.debug(`authentik/flows: redirecting to ${(this.challenge as RedirectChallenge).to}`);
|
this.redirect(this.challenge as RedirectChallenge);
|
||||||
if (localStorage.getItem(NEXT_ARG) === null) {
|
|
||||||
window.location.assign((this.challenge as RedirectChallenge).to);
|
|
||||||
} else {
|
|
||||||
localStorage.clear();
|
|
||||||
window.location.assign(localStorage.getItem(NEXT_ARG) || "");
|
|
||||||
}
|
|
||||||
return this.renderLoading();
|
return this.renderLoading();
|
||||||
case ChallengeTypeEnum.Shell:
|
case ChallengeTypeEnum.Shell:
|
||||||
return html`${unsafeHTML((this.challenge as ShellChallenge).body)}`;
|
return html`${unsafeHTML((this.challenge as ShellChallenge).body)}`;
|
||||||
|
|
Reference in New Issue