Skip to content

Using two or more auth strategies in a remix app #145

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

You must be logged in to vote

You can use any number of strategies, what you need to do is to call authenticator.use multiple times, one per strategy.

export let authenticator = new Authenticator<User>(sessionStorage, options)
authenticator
  .use(new FormStrategy(login))
  .use(new GoogleStrategy(googleOptions, login))

You could also do authenticator.use two times instead of chaining them.

Then, when you want to use one strategy you need to do authenticator.authenticate("form", request) or authenticator.authenticate("google", request), that's the reason why authenticate excepts the strategy name.

If you want to customize the strategy name pass it as second param of .use like this:

authenticator.use(new FormStrategy(l…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@binajmen
Comment options

@sergiodxa
Comment options

@binajmen
Comment options

Answer selected by sergiodxa
Comment options

You must be logged in to vote
1 reply
@sergiodxa
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants