Skip to content

Commit

Permalink
Fix redirect loop on home page (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca authored Aug 31, 2022
1 parent 50354cd commit 96c138c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const STATIC_PAGES = [
"/auth/datapass/login",
];

export const NON_AUTH_GUARDED_PAGES = [...STATIC_PAGES, "/"];

export const DATA_FORMAT_LABELS: { [K in DataFormat]: string } = {
file_tabular: "Fichier tabulaire (XLS, XLSX, CSV, ...)",
file_gis: "Fichier SIG (Shapefile, ...)",
Expand Down
4 changes: 2 additions & 2 deletions client/src/lib/auth/guard.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { get } from "svelte/store";
import type { LoadOutput } from "@sveltejs/kit";
import { user } from "../stores/auth";
import { STATIC_PAGES } from "src/constants";
import { NON_AUTH_GUARDED_PAGES } from "src/constants";
import { Maybe } from "$lib/util/maybe";

/**
* Force-redirect to the login page if an unauthenticated user
* is attempting to access a protected page.
*/
export const authGuard = (url: URL): LoadOutput => {
if (STATIC_PAGES.includes(url.pathname)) {
if (NON_AUTH_GUARDED_PAGES.includes(url.pathname)) {
return {};
}

Expand Down

0 comments on commit 96c138c

Please sign in to comment.