Skip to content

Backend to Main#61

Merged
lnqminh3003 merged 11 commits intomainfrom
backend
Feb 17, 2026
Merged

Backend to Main#61
lnqminh3003 merged 11 commits intomainfrom
backend

Conversation

@lnqminh3003
Copy link
Collaborator

No description provided.

lnqminh3003 and others added 11 commits February 6, 2026 22:14
- Add LinkedIn OAuth utility for auth URL generation, token exchange, and profile fetching
- Add linkedinAuth and linkedinCallback controllers with CSRF state token protection
- Update User model with OAuth fields (linkedinId, profilePhoto, authProvider) and make passwordHash optional
- Add pre-save validation ensuring local auth users still require passwords
- Handle email conflicts between OAuth and password-based accounts
- Add environment variable validation for LinkedIn credentials at startup
Add LinkedIn OAuth 2.0 authentication
Replace direct JWT token in redirect URL with a single-use auth code
pattern. The LinkedIn callback now generates a temporary code stored in
MongoDB (60s TTL), and the frontend exchanges it via POST /api/auth/exchange
for a JWT token. This prevents token exposure in browser history and URLs.
Upgrade the guest join flow to create a real User account with
authProvider 'guest', returning a JWT token so guests can access
protected routes and complete their profile later.

Add PUT /api/users/:userId endpoint for updating name, email, password,
bio, profilePhoto, and socialLinks. Guest users are upgraded to local
auth when they set a password. Users can only update their own profile.

Update User model to support guest accounts (email optional with sparse
index) and add bio/socialLinks fields.
Add secure auth code exchange for LinkedIn OAuth
Add quick signup and profile update endpoint
@lnqminh3003 lnqminh3003 merged commit cb0cda3 into main Feb 17, 2026
2 checks passed
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