check user is present
A session can exist without a user, if the user was recently deleted
This commit is contained in:
parent
a4deed23fe
commit
3691bd6f8f
2 changed files with 4 additions and 9 deletions
|
|
@ -11,7 +11,7 @@ export async function validateSession(event: ServerLoadEvent) {
|
|||
where: { id: sessionId },
|
||||
include: { user: true },
|
||||
});
|
||||
if (!session) {
|
||||
if (!session || !session.user) {
|
||||
redirect(300, '/login');
|
||||
}
|
||||
const expiry = session.expiresAt;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
import { validateSession } from '$lib/server/auth/index.js';
|
||||
|
||||
export async function load(event) {
|
||||
const {
|
||||
user: { password: _, ...rest },
|
||||
} = await validateSession(event);
|
||||
return {
|
||||
user: rest,
|
||||
};
|
||||
await validateSession(event);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue