Skip to content

Enhance user model and authentication controller: add personalRoomId,… - #2

Merged
Ashutoshmore24 merged 1 commit into
mainfrom
Auth
Aug 9, 2026
Merged

Enhance user model and authentication controller: add personalRoomId,…#2
Ashutoshmore24 merged 1 commit into
mainfrom
Auth

Conversation

@Ashutoshmore24

Copy link
Copy Markdown
Owner

… role, and isVerified fields; improve login and signup responses.

… role, and isVerified fields; improve login and signup responses.
Copilot AI lite review requested due to automatic review settings August 9, 2026 05:58
@Ashutoshmore24
Ashutoshmore24 merged commit 6f6d941 into main Aug 9, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the backend user/account model to support role-based metadata and a per-user “personal room” identifier, and updates authentication endpoints to return richer, structured user payloads on login/signup/profile.

Changes:

  • Add role, isVerified, and personalRoomId fields to the User Mongoose schema.
  • Enhance login, signup, and userProfile responses to return message plus a nested user object (including the new fields).
  • Generate a personalRoomId during signup using crypto.randomUUID().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
backend/src/models/User.js Adds new user attributes (role, isVerified, personalRoomId) to the persisted user schema.
backend/src/controllers/auth.controller.js Normalizes/enhances auth responses and generates/stores personalRoomId during signup.
Suppressed comments (1)

backend/src/controllers/auth.controller.js:57

  • fullName/email/password are assumed to be strings (password.length, email.toLowerCase()), but only truthiness is checked. Non-string inputs will throw and return 500. Add a type check and normalize the email before validation/querying.
  const { fullName, email, password } = req.body;
  try {
    if (!fullName || !email || !password) {
      return res.status(400).json({ message: "All fields are required" });
    }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +33 to +37
personalRoomId: {
type: String,
unique: true,
required: true,
},
Comment on lines +7 to +24
const { email, password } = req.body;
try {
if (!email || !password) {
return res.status(400).json({ message: "Both fields are required" });
}

if (password.length < 6) {
return res
.status(400)
.json({ message: "Password must be at least 6 characters long" });
}

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
return res.status(400).json({ message: "Invalid email format" });
}

const user = await User.findOne({ email: email.toLowerCase() });
Comment on lines +82 to +87
const newUser = new User({
fullName,
email: email.toLowerCase(),
password: hashedPassword,
personalRoomId,
});
Comment on lines +106 to +109
} catch (error) {
console.error("Signup Error:", error);
res.status(500).json({ message: "Internal Server Error" });
}
Comment on lines +114 to +119
res.clearCookie("jwt", {
maxAge: 0,
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants