diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 52762bbd..ea887d6f 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -11,8 +11,11 @@ export const authenticationHandler: Handle = async ({ event, resolve }) => { const { cookies, locals, url } = event; const sessionId = cookies.get('session_id'); + console.log('session id in hooks: ', sessionId); + console.log('cookies id in hooks: ', cookies.getAll()); if (sessionId && (!locals.user || !locals.authenticated)) { const user = await locals.openRegistry.getUserBySession(sessionId); + console.log('user id in hooks: ', user); if (user) { session.setUser(user); session.setIsAuthenticated(true); @@ -43,7 +46,9 @@ export const createProtobufClient: Handle = async ({ event, resolve }) => { export const isProtectedRoute = (route: string): boolean => { return ( - route.startsWith('/settings') || route.startsWith('/repositories') || route.startsWith('/apps') + route.startsWith('/settings') || + route.startsWith('/repositories') || + route.startsWith('/apps') ); }; diff --git a/src/lib/client/openregistry.ts b/src/lib/client/openregistry.ts index 0443b289..05850fe5 100644 --- a/src/lib/client/openregistry.ts +++ b/src/lib/client/openregistry.ts @@ -242,7 +242,10 @@ export class OpenRegistryClient { cookie: `session_id=${sessionId}` } }); - return OpenRegistryUserSchema.parse(await response.json()); + const data = await response.json(); + console.log('status in getUserBySession: ', response.status); + console.log('data in getUserBySession: ', data); + return OpenRegistryUserSchema.parse(data); } catch (err) { console.warn('error getting user from session: ', err); return null; @@ -281,7 +284,10 @@ export class OpenRegistryClient { credentialCreationOpts: CredentialCreationOptionsJSON ): Promise { const options = parseCreationOptionsFromJSON(credentialCreationOpts); - const url = new URL('/auth/webauthn/registration/finish', env.PUBLIC_OPEN_REGISTRY_BACKEND_URL); + const url = new URL( + '/auth/webauthn/registration/finish', + env.PUBLIC_OPEN_REGISTRY_BACKEND_URL + ); url.searchParams.set('username', username); let body: RegistrationPublicKeyCredential; try {