diff --git a/web/src/hooks.ts b/web/src/hooks.ts
index 788f169eb..245591124 100644
--- a/web/src/hooks.ts
+++ b/web/src/hooks.ts
@@ -1,6 +1,6 @@
import type { ExternalFetch, GetSession, Handle } from '@sveltejs/kit';
import * as cookie from 'cookie';
-import { api, serverApi } from '@api';
+import { serverApi } from '@api';
export const handle: Handle = async ({ event, resolve }) => {
const cookies = cookie.parse(event.request.headers.get('cookie') || '');
diff --git a/web/src/routes/admin/index.svelte b/web/src/routes/admin/index.svelte
index 641821802..c7e523db1 100644
--- a/web/src/routes/admin/index.svelte
+++ b/web/src/routes/admin/index.svelte
@@ -2,7 +2,14 @@
import type { Load } from '@sveltejs/kit';
import { api, UserResponseDto } from '@api';
- export const load: Load = async ({ fetch }) => {
+ export const load: Load = async ({ fetch, session }) => {
+ if (!browser && !session.user) {
+ return {
+ status: 302,
+ redirect: '/auth/login'
+ };
+ }
+
try {
const [user, allUsers] = await Promise.all([
fetch('/data/user/get-my-user-info').then((r) => r.json()),
@@ -37,6 +44,7 @@
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
import CreateUserForm from '$lib/components/forms/create-user-form.svelte';
import StatusBox from '$lib/components/shared-components/status-box.svelte';
+ import { browser } from '$app/env';
let selectedAction: AdminSideBarSelection = AdminSideBarSelection.USER_MANAGEMENT;
diff --git a/web/src/routes/albums/[albumId]/index.svelte b/web/src/routes/albums/[albumId]/index.svelte
index 7f1a2fd50..54256f336 100644
--- a/web/src/routes/albums/[albumId]/index.svelte
+++ b/web/src/routes/albums/[albumId]/index.svelte
@@ -4,7 +4,14 @@
import type { Load } from '@sveltejs/kit';
import { AlbumResponseDto } from '@api';
- export const load: Load = async ({ fetch, params }) => {
+ export const load: Load = async ({ fetch, params, session }) => {
+ if (!browser && !session.user) {
+ return {
+ status: 302,
+ redirect: '/auth/login'
+ };
+ }
+
try {
const albumId = params['albumId'];
@@ -36,6 +43,7 @@
diff --git a/web/src/routes/albums/[albumId]/photos/[assetId].svelte b/web/src/routes/albums/[albumId]/photos/[assetId].svelte
index e646a19f5..4349114cf 100644
--- a/web/src/routes/albums/[albumId]/photos/[assetId].svelte
+++ b/web/src/routes/albums/[albumId]/photos/[assetId].svelte
@@ -1,11 +1,10 @@
diff --git a/web/src/routes/photos/index.svelte b/web/src/routes/photos/index.svelte
index e2182ac01..7cd22bce7 100644
--- a/web/src/routes/photos/index.svelte
+++ b/web/src/routes/photos/index.svelte
@@ -3,8 +3,14 @@
import type { Load } from '@sveltejs/kit';
import { setAssetInfo } from '$lib/stores/assets';
+ export const load: Load = async ({ fetch, session }) => {
+ if (!browser && !session.user) {
+ return {
+ status: 302,
+ redirect: '/auth/login'
+ };
+ }
- export const load: Load = async ({ fetch }) => {
try {
const [userInfo, assets] = await Promise.all([
fetch('/data/user/get-my-user-info').then((r) => r.json()),
@@ -40,6 +46,7 @@
import { openFileUploadDialog, UploadType } from '$lib/utils/file-uploader';
import { AssetResponseDto, UserResponseDto } from '@api';
import SideBar from '$lib/components/shared-components/side-bar/side-bar.svelte';
+ import { browser } from '$app/env';
export let user: UserResponseDto;
diff --git a/web/src/routes/sharing/index.svelte b/web/src/routes/sharing/index.svelte
index 4c6196e57..1e9f92325 100644
--- a/web/src/routes/sharing/index.svelte
+++ b/web/src/routes/sharing/index.svelte
@@ -4,7 +4,14 @@
import type { Load } from '@sveltejs/kit';
import { AlbumResponseDto, api, UserResponseDto } from '@api';
- export const load: Load = async ({ fetch }) => {
+ export const load: Load = async ({ fetch, session }) => {
+ if (!browser && !session.user) {
+ return {
+ status: 302,
+ redirect: '/auth/login'
+ };
+ }
+
try {
const [user, sharedAlbums] = await Promise.all([
fetch('/data/user/get-my-user-info').then((r) => r.json()),
@@ -33,6 +40,7 @@
import PlusBoxOutline from 'svelte-material-icons/PlusBoxOutline.svelte';
import SharedAlbumListTile from '$lib/components/sharing-page/shared-album-list-tile.svelte';
import { goto } from '$app/navigation';
+ import { browser } from '$app/env';
export let user: UserResponseDto;
export let sharedAlbums: AlbumResponseDto[];