Skip to content

Commit 67badfc

Browse files
syuiloacid-chicken
authored andcommitted
fix(backend): use atomic command to improve security
Co-Authored-By: Acid Chicken <[email protected]>
1 parent 66c245e commit 67badfc

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

packages/backend/src/core/WebAuthnService.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,12 @@ export class WebAuthnService {
246246

247247
@bindThis
248248
public async verifyAuthentication(userId: MiUser['id'], response: AuthenticationResponseJSON): Promise<boolean> {
249-
const challenge = await this.redisClient.get(`webauthn:challenge:${userId}`);
249+
const challenge = await this.redisClient.getdel(`webauthn:challenge:${userId}`);
250250

251251
if (!challenge) {
252252
throw new IdentifiableError('2d16e51c-007b-4edd-afd2-f7dd02c947f6', 'challenge not found');
253253
}
254254

255-
await this.redisClient.del(`webauthn:challenge:${userId}`);
256-
257255
const key = await this.userSecurityKeysRepository.findOneBy({
258256
id: response.id,
259257
userId: userId,

0 commit comments

Comments
 (0)