Skip to content

Add LinkedIn account linking for guest and local users#108

Open
rxmox wants to merge 2 commits intobackendfrom
feature/linkedin-guest-linking
Open

Add LinkedIn account linking for guest and local users#108
rxmox wants to merge 2 commits intobackendfrom
feature/linkedin-guest-linking

Conversation

@rxmox
Copy link
Copy Markdown
Collaborator

@rxmox rxmox commented Apr 11, 2026

Summary

  • Add new GET /api/auth/linkedin/link protected endpoint that lets existing users (guest or local) link their LinkedIn profile
  • Guest users get fully upgraded to authProvider: 'linkedin' with LinkedIn profile data (name, email, photo)
  • Local users keep authProvider: 'local' (preserving password login) and gain linkedinId and profilePhoto from LinkedIn
  • Only fills in email, profilePhoto, and name when the user doesn't already have them set
  • Reuses the existing LinkedIn OAuth callback by encoding a linking context (linking: true, userId) in the signed state JWT

Error Handling

Status Condition
401 Missing or invalid JWT
403 Account is already a LinkedIn account
404 User not found
409 LinkedIn account already linked to another user

Files Changed

  • auth_controller.ts — New linkedinLink controller + updated linkedinCallback to handle linking flow
  • auth_routes.ts — Register /linkedin/link route with auth middleware
  • API_REFERENCE.md — Document the new endpoint

rxmox added 2 commits April 9, 2026 19:36
New GET /api/auth/linkedin/link endpoint (protected, guest-only) that
initiates LinkedIn OAuth with the guest user's identity encoded in the
state JWT. The existing linkedinCallback detects the linking context
and atomically upgrades the guest user to authProvider 'linkedin',
populating linkedinId, email, profilePhoto, and name from LinkedIn.

Includes validation for non-guest users (403), already-linked accounts
(409), and LinkedIn accounts already tied to another user.
Extends the linkedin/link endpoint to accept both guest and local
users. Guest users still get fully upgraded to authProvider 'linkedin'.
Local users keep authProvider 'local' (preserving password login) and
gain linkedinId and profilePhoto from LinkedIn. Only fills in email
and profilePhoto when the user doesn't already have them set.
@rxmox rxmox changed the title Feature/linkedin guest linking Add LinkedIn account linking for guest and local users Apr 11, 2026
@rxmox rxmox requested a review from lnqminh3003 April 11, 2026 17:10
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