mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-05 14:05:30 +02:00
refactor: rename builders to server
This commit is contained in:
20
packages/server/src/auth/random-password.ts
Normal file
20
packages/server/src/auth/random-password.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import bcrypt from "bcrypt";
|
||||
|
||||
export const generateRandomPassword = async () => {
|
||||
const passwordLength = 16;
|
||||
|
||||
const characters =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
let randomPassword = "";
|
||||
for (let i = 0; i < passwordLength; i++) {
|
||||
randomPassword += characters.charAt(
|
||||
Math.floor(Math.random() * characters.length),
|
||||
);
|
||||
}
|
||||
|
||||
const saltRounds = 10;
|
||||
|
||||
const hashedPassword = await bcrypt.hash(randomPassword, saltRounds);
|
||||
return { randomPassword, hashedPassword };
|
||||
};
|
||||
Reference in New Issue
Block a user