Browse Source

fix(api): update web-auth service to handle nullable user properties

pull/7630/head
KenTandrian 4 days ago
parent
commit
5f3dce3004
  1. 9
      apps/api/src/app/auth/web-auth.service.ts

9
apps/api/src/app/auth/web-auth.service.ts

@ -99,6 +99,11 @@ export class WebAuthService {
): Promise<AuthDeviceDto> { ): Promise<AuthDeviceDto> {
const user = this.request.user; const user = this.request.user;
const expectedChallenge = user.authChallenge; const expectedChallenge = user.authChallenge;
if (!expectedChallenge) {
throw new Error('Missing authentication challenge');
}
let verification: VerifiedRegistrationResponse; let verification: VerifiedRegistrationResponse;
try { try {
@ -213,7 +218,7 @@ export class WebAuthService {
id: isoBase64URL.fromBuffer(device.credentialId), id: isoBase64URL.fromBuffer(device.credentialId),
publicKey: device.credentialPublicKey publicKey: device.credentialPublicKey
}, },
expectedChallenge: `${user.authChallenge}`, expectedChallenge: `${user?.authChallenge}`,
expectedOrigin: this.expectedOrigin, expectedOrigin: this.expectedOrigin,
expectedRPID: this.rpID, expectedRPID: this.rpID,
requireUserVerification: false, requireUserVerification: false,
@ -243,7 +248,7 @@ export class WebAuthService {
}); });
return this.jwtService.sign({ return this.jwtService.sign({
id: user.id id: user?.id
}); });
} }

Loading…
Cancel
Save