Add redirecting user to login if session cookie is not found
This commit is contained in:
parent
9dbce2b331
commit
aa5a173e83
16
src/routes/+layout.server.ts
Normal file
16
src/routes/+layout.server.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { redirect } from "@sveltejs/kit";
|
||||
import type { LayoutServerLoad } from "./$types";
|
||||
|
||||
export const load: LayoutServerLoad = async ({ url, fetch, cookies }) => {
|
||||
if (url.pathname == "/login") {
|
||||
return
|
||||
}
|
||||
console.log("what?")
|
||||
const response = await fetch("https://api.fin.qowevisa.click/api/authping");
|
||||
|
||||
if (!response.ok) {
|
||||
cookies.delete('session', { path: "/" })
|
||||
|
||||
throw redirect(302, "/login");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user