Skip to content

Comments

Add JWT authentication routes + controller | Schema updates needed#15

Open
AshishSinsinwal wants to merge 3 commits intoThe-Debugging-Society:mainfrom
AshishSinsinwal:main
Open

Add JWT authentication routes + controller | Schema updates needed#15
AshishSinsinwal wants to merge 3 commits intoThe-Debugging-Society:mainfrom
AshishSinsinwal:main

Conversation

@AshishSinsinwal
Copy link

🚀 Implementation Summary

Completed Work:

  • Built secure /register and /login endpoints featuring:
    • JWT token generation (7-day expiry)
    • Password hashing via bcryptjs
    • Role-based access control (admin/owner/student)
    • Authentication middleware for protected routes

🛑 Required Schema Updates

The current User schema needs these additions for auth functionality:

Field Required Changes Purpose
email { type: String, required: true, unique: true } User identification
password { type: String, required: true } Store hashed passwords
timestamps { timestamps: true } Track account activity

Proposed Schema:

// Updated User model
const userSchema = new mongoose.Schema({
  name: { type: String, required: true },
  email: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  role: { 
    type: String, 
    required: true, 
    enum: ["admin", "owner", "student"],
    default: "student" 
  }
}, { timestamps: true });

 I can implement the schema changes , if u allows.

@vercel
Copy link

vercel bot commented Aug 3, 2025

@AshishSinsinwal is attempting to deploy a commit to the tanmay0215's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Aug 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pg-finder ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 4, 2025 8:50am

@Tanmay0215
Copy link
Contributor

please resolve the previous comments and also resolve the merge conflict

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