web: fix title not being loaded from config
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> #770
This commit is contained in:
parent
3282b34431
commit
c1ab5c5556
|
@ -1,4 +1,4 @@
|
|||
import { Configuration, Middleware, ResponseContext } from "authentik-api";
|
||||
import { Config, Configuration, Middleware, ResponseContext, RootApi } from "authentik-api";
|
||||
import { getCookie } from "../utils";
|
||||
import { API_DRAWER_MIDDLEWARE } from "../elements/notifications/APIDrawer";
|
||||
import { MessageMiddleware } from "../elements/messages/Middleware";
|
||||
|
@ -12,6 +12,14 @@ export class LoggingMiddleware implements Middleware {
|
|||
|
||||
}
|
||||
|
||||
let globalConfigPromise: Promise<Config>;
|
||||
export function config(): Promise<Config> {
|
||||
if (!globalConfigPromise) {
|
||||
globalConfigPromise = new RootApi(DEFAULT_CONFIG).rootConfigList();
|
||||
}
|
||||
return globalConfigPromise;
|
||||
}
|
||||
|
||||
export const DEFAULT_CONFIG = new Configuration({
|
||||
basePath: "/api/v2beta",
|
||||
headers: {
|
||||
|
|
|
@ -2,12 +2,12 @@ import * as Sentry from "@sentry/browser";
|
|||
import { Integrations } from "@sentry/tracing";
|
||||
import { VERSION } from "../constants";
|
||||
import { SentryIgnoredError } from "../common/errors";
|
||||
import { Config, RootApi } from "authentik-api";
|
||||
import { me } from "./Users";
|
||||
import { DEFAULT_CONFIG } from "./Config";
|
||||
import { config } from "./Config";
|
||||
import { Config } from "authentik-api";
|
||||
|
||||
export function configureSentry(): Promise<Config> {
|
||||
return new RootApi(DEFAULT_CONFIG).rootConfigList().then((config) => {
|
||||
return config().then((config) => {
|
||||
if (config.errorReportingEnabled) {
|
||||
Sentry.init({
|
||||
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { CoreApi, SessionUser } from "authentik-api";
|
||||
import { DEFAULT_CONFIG } from "./Config";
|
||||
|
||||
let _globalMePromise: Promise<SessionUser>;
|
||||
let globalMePromise: Promise<SessionUser>;
|
||||
export function me(): Promise<SessionUser> {
|
||||
if (!_globalMePromise) {
|
||||
_globalMePromise = new CoreApi(DEFAULT_CONFIG).coreUsersMe().catch((ex) => {
|
||||
if (!globalMePromise) {
|
||||
globalMePromise = new CoreApi(DEFAULT_CONFIG).coreUsersMe().catch((ex) => {
|
||||
const defaultUser: SessionUser = {
|
||||
user: {
|
||||
username: "",
|
||||
|
@ -17,5 +17,5 @@ export function me(): Promise<SessionUser> {
|
|||
return defaultUser;
|
||||
});
|
||||
}
|
||||
return _globalMePromise;
|
||||
return globalMePromise;
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ export const EVENT_REFRESH = "ak-refresh";
|
|||
export const EVENT_NOTIFICATION_TOGGLE = "ak-notification-toggle";
|
||||
export const EVENT_SIDEBAR_TOGGLE = "ak-sidebar-toggle";
|
||||
export const EVENT_API_DRAWER_REFRESH = "ak-api-drawer-refresh";
|
||||
export const TITLE_SUFFIX = "authentik";
|
||||
export const TITLE_DEFAULT = "authentik";
|
||||
export const ROUTE_SEPARATOR = ";";
|
||||
|
|
|
@ -4,7 +4,8 @@ import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|||
import AKGlobal from "../authentik.css";
|
||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||
import { EVENT_SIDEBAR_TOGGLE, TITLE_SUFFIX } from "../constants";
|
||||
import { EVENT_SIDEBAR_TOGGLE, TITLE_DEFAULT } from "../constants";
|
||||
import { config } from "../api/Config";
|
||||
|
||||
@customElement("ak-page-header")
|
||||
export class PageHeader extends LitElement {
|
||||
|
@ -17,11 +18,13 @@ export class PageHeader extends LitElement {
|
|||
|
||||
@property()
|
||||
set header(value: string) {
|
||||
config().then(config => {
|
||||
if (value !== "") {
|
||||
document.title = `${value} - ${TITLE_SUFFIX}`;
|
||||
document.title = `${value} - ${config.brandingTitle}`;
|
||||
} else {
|
||||
document.title = TITLE_SUFFIX;
|
||||
document.title = config.brandingTitle || TITLE_DEFAULT;
|
||||
}
|
||||
});
|
||||
this._header = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ import { WebAuthnAuthenticatorRegisterChallenge } from "./stages/authenticator_w
|
|||
import { CaptchaChallenge } from "./stages/captcha/CaptchaStage";
|
||||
import { StageHost } from "./stages/base";
|
||||
import { Challenge, ChallengeTypeEnum, Config, FlowsApi } from "authentik-api";
|
||||
import { DEFAULT_CONFIG } from "../api/Config";
|
||||
import { config, DEFAULT_CONFIG } from "../api/Config";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { AccessDeniedChallenge } from "./access_denied/FlowAccessDenied";
|
||||
import { PFSize } from "../elements/Spinner";
|
||||
import { TITLE_SUFFIX } from "../constants";
|
||||
import { TITLE_DEFAULT } from "../constants";
|
||||
import { configureSentry } from "../api/Sentry";
|
||||
|
||||
@customElement("ak-flow-executor")
|
||||
|
@ -99,11 +99,13 @@ export class FlowExecutor extends LitElement implements StageHost {
|
|||
}
|
||||
|
||||
private postUpdate(): void {
|
||||
config().then(config => {
|
||||
if (this.challenge?.title) {
|
||||
document.title = `${this.challenge.title} - ${TITLE_SUFFIX}`;
|
||||
document.title = `${this.challenge.title} - ${config.brandingTitle}`;
|
||||
} else {
|
||||
document.title = TITLE_SUFFIX;
|
||||
document.title = config.brandingTitle || TITLE_DEFAULT;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submit<T>(formData?: T): Promise<void> {
|
||||
|
|
|
@ -1665,8 +1665,8 @@ msgid "Library"
|
|||
msgstr "Library"
|
||||
|
||||
#: src/elements/table/Table.ts:120
|
||||
#: src/flows/FlowExecutor.ts:165
|
||||
#: src/flows/FlowExecutor.ts:211
|
||||
#: src/flows/FlowExecutor.ts:167
|
||||
#: src/flows/FlowExecutor.ts:213
|
||||
#: src/flows/access_denied/FlowAccessDenied.ts:27
|
||||
#: src/flows/stages/authenticator_static/AuthenticatorStaticStage.ts:43
|
||||
#: src/flows/stages/authenticator_totp/AuthenticatorTOTPStage.ts:33
|
||||
|
@ -2321,7 +2321,7 @@ msgstr "Post binding"
|
|||
msgid "Post binding (auto-submit)"
|
||||
msgstr "Post binding (auto-submit)"
|
||||
|
||||
#: src/flows/FlowExecutor.ts:253
|
||||
#: src/flows/FlowExecutor.ts:255
|
||||
msgid "Powered by authentik"
|
||||
msgstr "Powered by authentik"
|
||||
|
||||
|
@ -2575,7 +2575,7 @@ msgstr "Retry Task"
|
|||
msgid "Retry authentication"
|
||||
msgstr "Retry authentication"
|
||||
|
||||
#: src/flows/FlowExecutor.ts:143
|
||||
#: src/flows/FlowExecutor.ts:145
|
||||
msgid "Return"
|
||||
msgstr "Return"
|
||||
|
||||
|
@ -2823,7 +2823,7 @@ msgstr "Skip path regex"
|
|||
msgid "Slug"
|
||||
msgstr "Slug"
|
||||
|
||||
#: src/flows/FlowExecutor.ts:136
|
||||
#: src/flows/FlowExecutor.ts:138
|
||||
msgid "Something went wrong! Please try again later."
|
||||
msgstr "Something went wrong! Please try again later."
|
||||
|
||||
|
@ -3863,7 +3863,7 @@ msgstr "When selected, incoming assertion's Signatures will be validated against
|
|||
msgid "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
|
||||
msgstr "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
|
||||
|
||||
#: src/flows/FlowExecutor.ts:132
|
||||
#: src/flows/FlowExecutor.ts:134
|
||||
msgid "Whoops!"
|
||||
msgstr "Whoops!"
|
||||
|
||||
|
|
|
@ -1657,8 +1657,8 @@ msgid "Library"
|
|||
msgstr ""
|
||||
|
||||
#: src/elements/table/Table.ts:120
|
||||
#: src/flows/FlowExecutor.ts:165
|
||||
#: src/flows/FlowExecutor.ts:211
|
||||
#: src/flows/FlowExecutor.ts:167
|
||||
#: src/flows/FlowExecutor.ts:213
|
||||
#: src/flows/access_denied/FlowAccessDenied.ts:27
|
||||
#: src/flows/stages/authenticator_static/AuthenticatorStaticStage.ts:43
|
||||
#: src/flows/stages/authenticator_totp/AuthenticatorTOTPStage.ts:33
|
||||
|
@ -2313,7 +2313,7 @@ msgstr ""
|
|||
msgid "Post binding (auto-submit)"
|
||||
msgstr ""
|
||||
|
||||
#: src/flows/FlowExecutor.ts:253
|
||||
#: src/flows/FlowExecutor.ts:255
|
||||
msgid "Powered by authentik"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2567,7 +2567,7 @@ msgstr ""
|
|||
msgid "Retry authentication"
|
||||
msgstr ""
|
||||
|
||||
#: src/flows/FlowExecutor.ts:143
|
||||
#: src/flows/FlowExecutor.ts:145
|
||||
msgid "Return"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2815,7 +2815,7 @@ msgstr ""
|
|||
msgid "Slug"
|
||||
msgstr ""
|
||||
|
||||
#: src/flows/FlowExecutor.ts:136
|
||||
#: src/flows/FlowExecutor.ts:138
|
||||
msgid "Something went wrong! Please try again later."
|
||||
msgstr ""
|
||||
|
||||
|
@ -3851,7 +3851,7 @@ msgstr ""
|
|||
msgid "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
|
||||
msgstr ""
|
||||
|
||||
#: src/flows/FlowExecutor.ts:132
|
||||
#: src/flows/FlowExecutor.ts:134
|
||||
msgid "Whoops!"
|
||||
msgstr ""
|
||||
|
||||
|
|
Reference in a new issue