feat(auth): server-side sessions replacing Basic-auth cookie promotion (#523) #612
@@ -1,5 +1,5 @@
|
|||||||
import * as Sentry from '@sentry/sveltekit';
|
import * as Sentry from '@sentry/sveltekit';
|
||||||
import { redirect, type Handle, type HandleFetch } from '@sveltejs/kit';
|
import { isRedirect, redirect, type Handle, type HandleFetch } from '@sveltejs/kit';
|
||||||
import { paraglideMiddleware } from '$lib/paraglide/server';
|
import { paraglideMiddleware } from '$lib/paraglide/server';
|
||||||
import { sequence } from '@sveltejs/kit/hooks';
|
import { sequence } from '@sveltejs/kit/hooks';
|
||||||
import { env } from 'process';
|
import { env } from 'process';
|
||||||
@@ -87,10 +87,9 @@ const userGroup: Handle = async ({ event, resolve }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Don't swallow SvelteKit redirects — they're thrown as objects with a `status` field.
|
// Re-throw SvelteKit redirects (e.g. the /login?reason=expired throw above)
|
||||||
if (error instanceof Object && 'status' in error && 'location' in error) {
|
// using the official guard rather than duck-typing on the error shape.
|
||||||
throw error;
|
if (isRedirect(error)) throw error;
|
||||||
}
|
|
||||||
console.error('Error fetching user in hook:', error);
|
console.error('Error fetching user in hook:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user