Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ import type { Prefix } from "$lib/util";

export const ssr = false;

export async function load({ url }) {
export async function load({ url, fetch }) {
if (url.searchParams.has("detached")) {
return { detached: true };
}

if (storage.state.user) {
const response = await fetch("https://id.twitch.tv/oauth2/validate", {
headers: { Authorization: `OAuth ${storage.state.user.token}` },
Comment on lines +14 to +21
});

if (response.status === 401) {
log.info("Stored token expired, clearing user");
storage.state.user = null;
}
Comment on lines +24 to +27
}
Comment on lines +19 to +28

if (!storage.state.user) {
if (url.pathname !== "/auth/login") {
log.info("User not authenticated, redirecting to login");
Expand Down
Loading