Skip to content

feat: integrate mongodb authentication & session persistence - #76

Open
Crypticfr wants to merge 3 commits into
vicharanashala:mainfrom
Crypticfr:feat/mongodb-auth
Open

feat: integrate mongodb authentication & session persistence#76
Crypticfr wants to merge 3 commits into
vicharanashala:mainfrom
Crypticfr:feat/mongodb-auth

Conversation

@Crypticfr

Copy link
Copy Markdown

Description
This PR migrates the authentication flow to the new MongoDB backend while maintaining backwards compatibility with the legacy mock backend.

Key Changes
Dual-Backend Support: Configured concurrently to run the old backend on 3000 and the new MongoDB backend on 3001.
API Routing: Updated Vite proxy to route all /api traffic to the new backend by default.
Session Persistence: Implemented the /api/auth/me endpoint to query the database and securely restore user sessions via JWT on page refresh.
UI Bug Fixes: Injected a .name property into the TeacherModel transformer to fix a fatal React crash on the Teacher dashboard.
Backwards Compatibility: Updated frontend JSON parsers to handle both the new MongoDB ApiResponse wrapper format and the legacy flat format, ensuring local setups won't break.
How to test
Ensure your .env contains MONGO_URI and JWT_SECRET (leave PORT undefined).
Run npm run seed in the backend folder to populate the database.
Run npm run dev and test logging in
Refresh the page to verify session persistence.

@Crypticfr Crypticfr closed this Jul 22, 2026
@Crypticfr Crypticfr reopened this Jul 22, 2026
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.

1 participant