updated login flow

This commit is contained in:
2025-07-25 15:38:04 +05:30
parent ee74963058
commit fa1a34372b
7 changed files with 166 additions and 61 deletions

View File

@@ -17,13 +17,3 @@ export async function generateToken(): Promise<string> {
});
});
}
export function generateOTP() {
let otp = "";
for (let i = 0; i < 6; i++) {
otp += crypto.randomInt(10);
}
return parseInt(otp);
}

25
src/utils/password.ts Normal file
View File

@@ -0,0 +1,25 @@
export function validatePassword(password: string): boolean {
const charCounts = {
upper: 0,
lower: 0,
number: 0,
special: 0,
};
for (const char of password.split("")) {
if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(char)) charCounts.upper++;
if ("abcdefghijklmnopqrstuvwxyz".includes(char)) charCounts.lower++;
if ("0123456789".includes(char)) charCounts.number++;
if ("!@#$%^&*()<>?;:{}[]~".includes(char)) charCounts.special++;
}
if (
charCounts.upper >= 2 &&
charCounts.lower >= 2 &&
charCounts.number >= 2 &&
charCounts.special >= 2
)
return true;
return false;
}