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