diff --git a/materialious/src/lib/misc.ts b/materialious/src/lib/misc.ts index 50629233..98392262 100644 --- a/materialious/src/lib/misc.ts +++ b/materialious/src/lib/misc.ts @@ -1,4 +1,4 @@ -import { pushState } from '$app/navigation'; +import { goto, pushState } from '$app/navigation'; import { resolve } from '$app/paths'; import he from 'he'; import type Peer from 'peerjs'; @@ -240,3 +240,9 @@ export function logoutStores() { playlistCacheStore.set({}); channelCacheStore.set({}); } + +export function authProtected() { + if (!get(authStore) && !isYTBackend()) { + goto(resolve('/', {}), { replaceState: true }); + } +} diff --git a/materialious/src/routes/(app)/subscriptions/+page.ts b/materialious/src/routes/(app)/subscriptions/+page.ts index fcf60edf..6b2e3953 100644 --- a/materialious/src/routes/(app)/subscriptions/+page.ts +++ b/materialious/src/routes/(app)/subscriptions/+page.ts @@ -1,7 +1,7 @@ import { getFeed } from '$lib/api/index'; import type { PlaylistPageVideo, Video, VideoBase } from '$lib/api/model'; import { localDb } from '$lib/dexie'; -import { excludeDuplicateFeeds } from '$lib/misc'; +import { authProtected, excludeDuplicateFeeds } from '$lib/misc'; import { feedCacheStore } from '$lib/store'; import { error } from '@sveltejs/kit'; import { get } from 'svelte/store'; @@ -35,6 +35,8 @@ async function sortVideosByFavourites(videos: supportedVideos): Promise