Skip to content

Commit a784aa3

Browse files
committed
fix: password len fix and includes special chars
1 parent c0b30cf commit a784aa3

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/app/api/users/signup/route.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ export async function POST(request: NextRequest) {
4040
);
4141
}
4242

43-
const password = crypto.randomBytes(8).toString('hex');
43+
let randomBytes = crypto.randomBytes(8);
44+
const specialChars = "!@#$%^&*()_+~`|}{[]\:;?><,./-=";
45+
const allChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + specialChars;
46+
47+
for (let i = 0; i < randomBytes.length; i++) {
48+
randomBytes[i] = allChars.charCodeAt(randomBytes[i] % allChars.length);
49+
}
50+
51+
let password = randomBytes.toString('utf-8');
52+
4453

4554

4655
// Hash password before saving to DB

0 commit comments

Comments
 (0)