web: fix title not being loaded from config
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> #770
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user