new clients functionality

This commit is contained in:
Rajpreet0 2026-09-27 18:57:56 +02:00
parent 9dbacf4d45
commit 5edd697056
25 changed files with 1268 additions and 56 deletions

29
lib/generate-password.ts Normal file
View file

@ -0,0 +1,29 @@
import { randomInt } from "crypto"
const LOWERCASE = "abcdefghijkmnpqrstuvwxyz"
const UPPERCASE = "ABCDEFGHJKLMNPQRSTUVWXYZ"
const DIGITS = "23456789"
const SYMBOLS = "!@#$%&*"
const ALL_CHARS = LOWERCASE + UPPERCASE + DIGITS + SYMBOLS
export function generatePassword(length = 14) {
const required = [
LOWERCASE[randomInt(LOWERCASE.length)],
UPPERCASE[randomInt(UPPERCASE.length)],
DIGITS[randomInt(DIGITS.length)],
SYMBOLS[randomInt(SYMBOLS.length)],
]
const rest = Array.from({ length: length - required.length }, () =>
ALL_CHARS[randomInt(ALL_CHARS.length)]
)
const password = [...required, ...rest]
for (let i = password.length - 1; i > 0; i--) {
const j = randomInt(i + 1)
;[password[i], password[j]] = [password[j], password[i]]
}
return password.join("")
}