Skip to content

Commit

Permalink
web/flows: don't autoclose in redirect stage if redirecting to non-ht…
Browse files Browse the repository at this point in the history
…tp protocol (#5506)

Signed-off-by: Jens Langhammer <[email protected]>
  • Loading branch information
BeryJu authored May 7, 2023
1 parent 080f2ab commit 395dc08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
32 changes: 10 additions & 22 deletions web/src/flow/providers/oauth2/DeviceCodeFinish.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
import "@goauthentik/elements/EmptyState";
import "@goauthentik/flow/FormStatic";
import { AccessDeniedStage } from "@goauthentik/flow/stages/access_denied/AccessDeniedStage";
import { BaseStage } from "@goauthentik/flow/stages/base";

import { t } from "@lingui/macro";

import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js";

import { OAuthDeviceCodeFinishChallenge } from "@goauthentik/api";

@customElement("ak-flow-provider-oauth2-code-finish")
export class DeviceCodeFinish extends AccessDeniedStage {
export class DeviceCodeFinish extends BaseStage<
OAuthDeviceCodeFinishChallenge,
OAuthDeviceCodeFinishChallenge
> {
render(): TemplateResult {
if (!this.challenge) {
return html`<ak-empty-state ?loading="${true}" header=${t`Loading`}> </ak-empty-state>`;
}
return html`<header class="pf-c-login__main-header">
<h1 class="pf-c-title pf-m-3xl">${this.challenge.flowInfo?.title}</h1>
</header>
<div class="pf-c-login__main-body">
<form class="pf-c-form">
<div class="pf-c-form__group">
<p class="big-icon">
<i class="pf-icon pf-icon-ok"></i>
</p>
<h3 class="pf-c-title pf-m-3xl reason">
${t`You've successfully authenticated your device.`}
</h3>
<hr />
<p>${t`You can close this tab now.`}</p>
</div>
</form>
</div>
<footer class="pf-c-login__main-footer">
<ul class="pf-c-login__main-footer-links"></ul>
</footer>`;
return html`<ak-empty-state icon="fas fa-check" header=${t`You may close this page now.`}>
<span slot="body"> ${t`You've successfully authenticated your device.`} </span>
</ak-empty-state>`;
}
}
3 changes: 0 additions & 3 deletions web/src/flow/stages/RedirectStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ export class RedirectStage extends BaseStage<RedirectChallenge, FlowChallengeRes
// As this wouldn't really be a redirect, show a message that the page can be closed
// and try to close it ourselves
if (!url.protocol.startsWith("http")) {
setTimeout(() => {
window.close();
}, 500);
return html`<ak-empty-state
icon="fas fa-check"
header=${t`You may close this page now.`}
Expand Down

0 comments on commit 395dc08

Please sign in to comment.