web/user: add language selection
closes #2041 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		| @ -1,10 +1,21 @@ | ||||
| import { CoreApi, SessionUser } from "@goauthentik/api"; | ||||
| import { i18n } from "@lingui/core"; | ||||
| import { DEFAULT_CONFIG } from "./Config"; | ||||
|  | ||||
| let globalMePromise: Promise<SessionUser>; | ||||
| export function me(): Promise<SessionUser> { | ||||
|     if (!globalMePromise) { | ||||
|         globalMePromise = new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve().catch((ex) => { | ||||
|         globalMePromise = new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve().then((user) => { | ||||
|             if (!user.user.settings || !("locale" in user.user.settings)) { | ||||
|                 return user; | ||||
|             } | ||||
|             const locale = user.user.settings.locale; | ||||
|             if (locale && locale !== "") { | ||||
|                 console.debug(`authentik/locale: Activating user's configured locale '${locale}'`); | ||||
|                 i18n.activate(locale); | ||||
|             } | ||||
|             return user; | ||||
|         }).catch((ex) => { | ||||
|             const defaultUser: SessionUser = { | ||||
|                 user: { | ||||
|                     pk: -1, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer