From 5f3dce3004719bb06863cd912f21488177e19be5 Mon Sep 17 00:00:00 2001 From: KenTandrian Date: Sat, 15 Aug 2026 16:17:01 +0700 Subject: [PATCH] fix(api): update web-auth service to handle nullable user properties --- apps/api/src/app/auth/web-auth.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/auth/web-auth.service.ts b/apps/api/src/app/auth/web-auth.service.ts index cb9dd8cb7..568822fb8 100644 --- a/apps/api/src/app/auth/web-auth.service.ts +++ b/apps/api/src/app/auth/web-auth.service.ts @@ -99,6 +99,11 @@ export class WebAuthService { ): Promise { const user = this.request.user; const expectedChallenge = user.authChallenge; + + if (!expectedChallenge) { + throw new Error('Missing authentication challenge'); + } + let verification: VerifiedRegistrationResponse; try { @@ -213,7 +218,7 @@ export class WebAuthService { id: isoBase64URL.fromBuffer(device.credentialId), publicKey: device.credentialPublicKey }, - expectedChallenge: `${user.authChallenge}`, + expectedChallenge: `${user?.authChallenge}`, expectedOrigin: this.expectedOrigin, expectedRPID: this.rpID, requireUserVerification: false, @@ -243,7 +248,7 @@ export class WebAuthService { }); return this.jwtService.sign({ - id: user.id + id: user?.id }); }