web: fix linting errors by adding a wrapper for next param

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-06 13:19:39 +01:00
parent 3c01a1dd7b
commit 011babbbd9
5 changed files with 20 additions and 9 deletions

View File

@ -61,4 +61,11 @@ export const DEFAULT_CONFIG = new Configuration({
], ],
}); });
// This is just a function so eslint doesn't complain about
// missing-whitespace-between-attributes or
// unexpected-character-in-attribute-name
export function AndNext(url: string): string {
return `?next=${encodeURIComponent(url)}`;
}
console.debug(`authentik(early): version ${VERSION}, apiBase ${DEFAULT_CONFIG.basePath}`); console.debug(`authentik(early): version ${VERSION}, apiBase ${DEFAULT_CONFIG.basePath}`);

View File

@ -14,7 +14,7 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { Flow, FlowsApi } from "@goauthentik/api"; import { Flow, FlowsApi } from "@goauthentik/api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { AndNext, DEFAULT_CONFIG } from "../../api/Config";
import "../../elements/PageHeader"; import "../../elements/PageHeader";
import "../../elements/Tabs"; import "../../elements/Tabs";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
@ -100,7 +100,11 @@ export class FlowViewPage extends LitElement {
slug: this.flow.slug, slug: this.flow.slug,
}) })
.then((link) => { .then((link) => {
const finalURL = `${link.link}?next=/%23${window.location.hash}`; const finalURL = `${
link.link
}${AndNext(
`${window.location.pathname}#${window.location.hash}`,
)}`;
window.open(finalURL, "_blank"); window.open(finalURL, "_blank");
}); });
}} }}

View File

@ -13,6 +13,8 @@ import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css"; import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { AndNext } from "../../../api/Config";
@customElement("ak-user-settings-password") @customElement("ak-user-settings-password")
export class UserSettingsPassword extends LitElement { export class UserSettingsPassword extends LitElement {
@property() @property()
@ -29,7 +31,7 @@ export class UserSettingsPassword extends LitElement {
<div class="pf-c-card__title">${t`Change your password`}</div> <div class="pf-c-card__title">${t`Change your password`}</div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<a <a
href="${ifDefined(this.configureUrl)}?next=${encodeURIComponent( href="${ifDefined(this.configureUrl)}${AndNext(
"/if/user/#/settings;page-details", "/if/user/#/settings;page-details",
)}" )}"
class="pf-c-button pf-m-primary" class="pf-c-button pf-m-primary"

View File

@ -8,7 +8,7 @@ import { until } from "lit/directives/until.js";
import { AuthenticatorsApi, Device, UserSetting } from "@goauthentik/api"; import { AuthenticatorsApi, Device, UserSetting } from "@goauthentik/api";
import { AKResponse } from "../../../api/Client"; import { AKResponse } from "../../../api/Client";
import { DEFAULT_CONFIG } from "../../../api/Config"; import { AndNext, DEFAULT_CONFIG } from "../../../api/Config";
import "../../../elements/buttons/Dropdown"; import "../../../elements/buttons/Dropdown";
import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/ModalButton";
import "../../../elements/buttons/TokenCopyButton"; import "../../../elements/buttons/TokenCopyButton";
@ -78,9 +78,7 @@ export class MFADevicesPage extends Table<Device> {
.map((stage) => { .map((stage) => {
return html`<li> return html`<li>
<a <a
href="${ifDefined( href="${ifDefined(stage.configureUrl)}${AndNext(
stage.configureUrl,
)}?next=${encodeURIComponent(
"/if/user/#/settings;page-mfa", "/if/user/#/settings;page-mfa",
)}" )}"
class="pf-c-dropdown__menu-item" class="pf-c-dropdown__menu-item"

View File

@ -7,7 +7,7 @@ import { until } from "lit/directives/until.js";
import { SourcesApi } from "@goauthentik/api"; import { SourcesApi } from "@goauthentik/api";
import { DEFAULT_CONFIG } from "../../../api/Config"; import { AndNext, DEFAULT_CONFIG } from "../../../api/Config";
import { BaseUserSettings } from "../BaseUserSettings"; import { BaseUserSettings } from "../BaseUserSettings";
@customElement("ak-user-settings-source-oauth") @customElement("ak-user-settings-source-oauth")
@ -47,7 +47,7 @@ export class SourceSettingsOAuth extends BaseUserSettings {
return html`<p>${t`Not connected.`}</p> return html`<p>${t`Not connected.`}</p>
<a <a
class="pf-c-button pf-m-primary" class="pf-c-button pf-m-primary"
href="${ifDefined(this.configureUrl)}?next=${encodeURIComponent( href="${ifDefined(this.configureUrl)}${AndNext(
"/if/user/#/settings;page-sources", "/if/user/#/settings;page-sources",
)}" )}"
> >