-
Couldn't load subscription status.
- Fork 16
feat: session expiry feature implemented #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: session expiry feature implemented #51
Conversation
|
@anandshukla15 pls resolve merge conflicts carefully at first |
|
@04shubham7 done |
There was a problem hiding this comment.
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 implements JWT-based session management with a 7-day expiration period and logout functionality. The implementation introduces database-backed session tracking using MongoDB and automated cleanup of expired sessions.
Key changes:
- Session persistence layer added via a new
sessionModelto track active user sessions - Logout endpoint implemented to invalidate sessions by removing them from the database
- Automated cron job scheduled to clean up expired sessions daily at 2 AM
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/src/models/sessionModel.ts | Defines the Session schema with TTL index for automatic MongoDB expiration |
| backend/src/controllers/authController.ts | Creates session records during registration and login |
| backend/src/middleware/authMiddleware.ts | Validates tokens against active sessions in the database |
| backend/src/routes/authRoutes.ts | Adds logout endpoint to delete session records |
| backend/src/server.ts | Schedules daily cron job to clean up expired sessions |
| backend/src/utils/generateToken.ts | Refactored to use clearer variable naming (userId instead of id) |
| backend/package.json | Adds node-cron dependency for scheduled tasks |
| backend/tsconfig.tsbuildinfo | Updated build manifest to include sessionModel |
Files not reviewed (1)
- backend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good work
|
@anandshukla15 pls resolve merge conflicts |
Description
Semver Changes
-code of session expiry of period 7 days and logout functionality
Checklist
I have read the Contributing Guidelines.