Add LinkedIn account linking for guest and local users#108
Open
Add LinkedIn account linking for guest and local users#108
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/auth/linkedin/linkprotected endpoint that lets existing users (guest or local) link their LinkedIn profileauthProvider: 'linkedin'with LinkedIn profile data (name, email, photo)authProvider: 'local'(preserving password login) and gainlinkedinIdandprofilePhotofrom LinkedInlinking: true,userId) in the signed state JWTError Handling
Files Changed
auth_controller.ts— NewlinkedinLinkcontroller + updatedlinkedinCallbackto handle linking flowauth_routes.ts— Register/linkedin/linkroute with auth middlewareAPI_REFERENCE.md— Document the new endpoint