Skip to content

Protecting a route with 2 login steps (i.e. login and 2FA) fails to redirect #221

Description

@eladbs

Hi,
I'm trying to implement a 2 step log in (normal user/pass login and a 2FA login).
My route setup is something like this:

    <Route path="/" component={App}>
      <IndexRedirect to="VeryProtectedRoute"/>
      <Route path="login" component={userIsNotAuthenticated(Login)}/>
      <Route path="2FALogin" component={userIsAuthenticated(userIsNot2FAAuthenticated(2FALogin))}/>
      <Route path="VeryProtectedRoute" component={userIsAuthenticated(userIs2FAAuthenticated(VeryProtectedComponent))}/>
    </Route>

The process is like this:

  1. I try to go to /VeryProtectedRoute.
  2. I get redirected to /login?redirect=%2FVeryProtectedRoute.
  3. I login successfully.
  4. I get redirected to /VeryProtectedRoute.
  5. I get redirected to /2FALogin.
  6. I 2fa login successfully.
  7. I stay in /2FALogin and I am NOT redirected to /VeryProtectedRoute.

The problem is in step 5 - The URL i'm being redirected to lacks the "redirect" query param like in step 2. It should redirect me to "/2FALogin?redirect=%2FVeryProtectedRoute"....

Any clues on where to start look for a solution or the error in not adding the redirect?

Currently, we manually add the "redirect" query param but we'd like to have a general working code...
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions