Skip to content

Commit

Permalink
✨ Add logout route
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed May 13, 2024
1 parent 10b2fe4 commit 078091b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/src/openarchiefbeheer/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
#
SESSION_COOKIE_SAMESITE = config("SESSION_COOKIE_SAMESITE", "Lax")
SESSION_COOKIE_SECURE = config("SESSION_COOKIE_SECURE", IS_HTTPS)
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_HTTPONLY = config("SESSION_COOKIE_HTTPONLY", True)

CSRF_COOKIE_SAMESITE = config("CSRF_COOKIE_SAMESITE", "Lax")
CSRF_COOKIE_SECURE = config("CSRF_COOKIE_SECURE", IS_HTTPS)
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { RouterProvider, createBrowserRouter } from "react-router-dom";

import App from "./App";
import "./index.css";
import { loginRequired } from "./lib/api/loginRequired";
import { listReviewers } from "./lib/api/reviewers";
import { LandingPage, LoginPage, landingLoader, loginAction } from "./pages";
import {
LandingPage,
LoginPage,
landingLoader,
loginAction,
logoutLoader,
} from "./pages";

const router = createBrowserRouter([
{
Expand All @@ -19,6 +23,10 @@ const router = createBrowserRouter([
element: <LoginPage />,
action: loginAction,
},
{
path: "/logout",
loader: logoutLoader,
},
]);

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/cookie/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ export function getCookie(name: string): string | null {
}
return null;
}

/**
* Deletes a cookie.
* @param name
*/
export function deleteCookie(name: string) {
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/";
}
1 change: 1 addition & 0 deletions frontend/src/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Auto-generated file. Do not modify manually.
export * from "./landing";
export * from "./login";
export * from "./logout";

0 comments on commit 078091b

Please sign in to comment.