mirror of
https://github.com/outline/outline.git
synced 2026-12-06 11:12:32 +03:00
fix: Use safeEqual in VerificationCode verify method (#9915)
This commit is contained in:
1 parent
e8046f0d2f
commit
23106bfce8
1 file changed
+4
-3
@@ -1,6 +1,7 @@
|
||||
import { randomInt } from "crypto";
|
||||
import { Minute } from "@shared/utils/time";
|
||||
import Redis from "@server/storage/redis";
|
||||
import { safeEqual } from "./crypto";
|
||||
|
||||
/**
|
||||
* This class manages verification codes for email authentication.
|
||||
@@ -53,9 +54,9 @@ export class VerificationCode {
|
||||
* @param email The email address associated with the code
|
||||
* @returns Promise resolving to the code or null if not found
|
||||
*/
|
||||
public static async retrieve(email: string): Promise<string | null> {
|
||||
public static async retrieve(email: string): Promise<string | undefined> {
|
||||
const key = this.getKey(email);
|
||||
return await this.redis.get(key);
|
||||
return (await this.redis.get(key)) ?? undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,7 @@ export class VerificationCode {
|
||||
*/
|
||||
public static async verify(email: string, code: string): Promise<boolean> {
|
||||
const storedCode = await this.retrieve(email);
|
||||
return storedCode === code;
|
||||
return safeEqual(storedCode, code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user