mirror of
https://github.com/versia-pub/frontend.git
synced 2026-06-14 07:29:15 +02:00
chore: ⬆️ Upgrade to Nuxt 4
Some checks failed
Some checks failed
This commit is contained in:
parent
8debe97f63
commit
7f7cf20311
386 changed files with 2376 additions and 2332 deletions
22
app/utils/passwords.ts
Normal file
22
app/utils/passwords.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Get the strength of a password
|
||||
* @param password The password to check
|
||||
* @returns Number from 0 to Infinity representing the strength of the password
|
||||
*/
|
||||
export const passwordStrength = (password: string): number => {
|
||||
const length = password.length;
|
||||
const specialChars = password.match(/[^A-Za-z0-9]/g)?.length || 0;
|
||||
const numbers = password.match(/[0-9]/g)?.length || 0;
|
||||
const upperCase = password.match(/[A-Z]/g)?.length || 0;
|
||||
const lowerCase = password.match(/[a-z]/g)?.length || 0;
|
||||
|
||||
// Calculate the strength of the password
|
||||
return (
|
||||
(length * 4 +
|
||||
specialChars * 6 +
|
||||
numbers * 4 +
|
||||
upperCase * 2 +
|
||||
lowerCase * 2) /
|
||||
16
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue