Skip to content

Commit

Permalink
Fix login page redirect when login_link is not configured (#1117)
Browse files Browse the repository at this point in the history
When no login link is set, the "on load" redirect does not make sense.
Before this commit, refreshing the login page would redirect you to the
previous page, which is not intended.
  • Loading branch information
owi92 authored Feb 22, 2024
2 parents 7829194 + 77ee92d commit 2c8161e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "./i18n";
import { matchInitialRoute } from "./router";
import { LoginRoute, REDIRECT_STORAGE_KEY } from "./routes/Login";
import { checkInitialConsent } from "./ui/InitialConsent";
import CONFIG from "./config";


const redirect = (target: string) => {
Expand Down Expand Up @@ -44,7 +45,7 @@ const redirect = (target: string) => {
// a component to trigger a redirect. In fact, that approach would break in
// `StrictMode`.
const target = window.sessionStorage.getItem(REDIRECT_STORAGE_KEY);
if (window.location.pathname === LoginRoute.url && target) {
if (window.location.pathname === LoginRoute.url && target && CONFIG.auth.loginLink) {
// eslint-disable-next-line no-console
console.debug(`Requested login page after login: redirecting to previous page ${target}`);
redirect(target);
Expand Down

0 comments on commit 2c8161e

Please sign in to comment.