Skip to content

Commit dedf12e

Browse files
committed
Use cryptographically secure password generation for GitHub OAuth users
1 parent 736b193 commit dedf12e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

backend/routes/auth.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const express = require("express");
22
const passport = require("passport");
33
const User = require("../models/User");
4+
const crypto = require("crypto");
45
const router = express.Router();
56

67
// Signup route
@@ -103,8 +104,8 @@ router.post("/github/callback", async (req, res) => {
103104
githubId: userData.id.toString(), // Convert to string
104105
githubUsername: userData.login,
105106
avatarUrl: userData.avatar_url,
106-
// Set a random password since GitHub users don't have passwords
107-
password: Math.random().toString(36).slice(-10) + Math.random().toString(36).slice(-10)
107+
// Set a cryptographically secure random password
108+
password: crypto.randomBytes(32).toString('hex')
108109
});
109110
await user.save();
110111
} else {

0 commit comments

Comments
 (0)