updated login flow
This commit is contained in:
@@ -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
25
src/utils/password.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user