Skip to content

Commit 882d46e

Browse files
Merge pull request #101 from sofaspawn/sofaspawn/password-len-fix
Sofaspawn/password len fix
2 parents 6514c5a + 08cbe80 commit 882d46e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

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

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

43-
const password = crypto.randomBytes(8).toString('hex');
44-
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+
// console.log(password);
4553

4654
// Hash password before saving to DB
4755
const salt = await bcryptjs.genSalt(10);

0 commit comments

Comments
 (0)