Debug: log JWT token IDs og bruk authentik_sub som user.id
This commit is contained in:
parent
7eb7c2f1db
commit
3d3c99cb0d
1 changed files with 9 additions and 3 deletions
|
|
@ -48,16 +48,22 @@ export const { handle, signIn, signOut } = SvelteKitAuth({
|
|||
secret: env.AUTH_SECRET || 'dev-secret-not-for-production',
|
||||
trustHost: true,
|
||||
callbacks: {
|
||||
jwt({ token, user }) {
|
||||
jwt({ token, user, profile }) {
|
||||
if (user) {
|
||||
token.id = user.id;
|
||||
}
|
||||
if (profile?.sub) {
|
||||
token.authentik_sub = profile.sub;
|
||||
}
|
||||
console.log('[jwt] token.id:', token.id, 'token.sub:', token.sub, 'token.authentik_sub:', token.authentik_sub, 'user?.id:', user?.id);
|
||||
return token;
|
||||
},
|
||||
session({ session, token }) {
|
||||
if (session.user && token.id) {
|
||||
session.user.id = token.id as string;
|
||||
if (session.user) {
|
||||
// Bruk Authentik sub som user.id for å matche users-tabellen
|
||||
session.user.id = (token.authentik_sub ?? token.id) as string;
|
||||
}
|
||||
console.log('[session] user.id:', session.user?.id);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue