Added implementation for base page and log in log out

This commit is contained in:
fedyna-k
2025-01-14 23:34:40 +01:00
parent 9a97591bda
commit ccad788e19
27 changed files with 374 additions and 479 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Handlers } from "$fresh/server.ts";
import { State } from "./_middleware.ts";
import { deleteCookie } from "$std/http/cookie.ts";
const SERVICE = "https://localhost/";
const CAS = "https://ident.univ-amu.fr/cas";
export const handler: Handlers<any, State> = {
async GET(request, context) {
if (context.state.isAuthenticated) {
const headers = new Headers();
deleteCookie(headers, "sessionToken", { path: "/" });
headers.set("Location", `${CAS}/logout?service=${SERVICE}`);
return new Response(null, {
status: 302,
headers
});
}
else {
return new Response(null, {
status: 302,
headers: {
Location: "/"
}
});
}
}
};