Skip to content

remix-auth and linked accounts #289

Closed Answered by sergiodxa
caprica asked this question in Q&A
Discussion options

You must be logged in to vote

You need to trigger the second strategy, then in the callback of the strategy you can use the request to know if it's already authenticated and link the account, or create a new one.

authenticator.use(
  new GitHubStrategy(options, async ({ request, tokens }) => {
    let profile = await fetchGitHubProfile(tokens)
    let currentUser = await queryCurrentUser(request)
    if (currentUser) {
      await linkAccount(currentUser, profile)
      return currentUser;
    }
    return await createAccount(profile)
  })
)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sergiodxa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants