diff --git a/authentik/core/urls.py b/authentik/core/urls.py index c587a1961..7d8bedee9 100644 --- a/authentik/core/urls.py +++ b/authentik/core/urls.py @@ -14,7 +14,9 @@ from authentik.core.views.session import EndSessionView urlpatterns = [ path( "", - login_required(RedirectView.as_view(pattern_name="authentik_core:if-user")), + login_required( + RedirectView.as_view(pattern_name="authentik_core:if-user", query_string=True) + ), name="root-redirect", ), path( diff --git a/authentik/providers/oauth2/urls.py b/authentik/providers/oauth2/urls.py index 075fc64d5..1cbcb1a92 100644 --- a/authentik/providers/oauth2/urls.py +++ b/authentik/providers/oauth2/urls.py @@ -37,7 +37,7 @@ urlpatterns = [ ), path( "/end-session/", - RedirectView.as_view(pattern_name="authentik_core:if-session-end"), + RedirectView.as_view(pattern_name="authentik_core:if-session-end", query_string=True), name="end-session", ), path("/jwks/", JWKSView.as_view(), name="jwks"), diff --git a/web/src/api/Users.ts b/web/src/api/Users.ts index 616db9169..9c325405f 100644 --- a/web/src/api/Users.ts +++ b/web/src/api/Users.ts @@ -43,7 +43,10 @@ export function me(): Promise { }, }; 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; }); diff --git a/web/src/interfaces/AdminInterface.ts b/web/src/interfaces/AdminInterface.ts index 62bc38180..4426e9556 100644 --- a/web/src/interfaces/AdminInterface.ts +++ b/web/src/interfaces/AdminInterface.ts @@ -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) => {