web: fix redirect when accessing authentik URLs authenticated

closes #3174

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-06-30 22:37:29 +02:00
parent b7558ae28c
commit 56fd436e5d
4 changed files with 13 additions and 8 deletions

View File

@ -43,7 +43,10 @@ export function me(): Promise<SessionUser> {
},
};
if (ex.response.status === 401 || ex.response.status === 403) {
window.location.assign("/");
const relativeUrl = window.location
.toString()
.substring(window.location.origin.length);
window.location.assign(`/flows/-/default/authentication/?next=${encodeURIComponent(relativeUrl)}`);
}
return defaultUser;
});

View File

@ -100,6 +100,11 @@ export class AdminInterface extends LitElement {
});
});
this.version = new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve();
me().then((u) => {
if (!u.user.isSuperuser && u.user.pk > 0) {
window.location.assign("/if/user");
}
});
}
render(): TemplateResult {
@ -150,11 +155,6 @@ export class AdminInterface extends LitElement {
}
renderSidebarItems(): TemplateResult {
me().then((u) => {
if (!u.user.isSuperuser) {
window.location.assign("/if/user");
}
});
return html`
${until(
this.version.then((version) => {