Redirection when unautheticated not working

Hi there!
I’m trying to setup an app with authentication (dbAuth). I followed the tutorial (great, by the way) but my router does not redirect me to the login page.

My Route.js looks like this:

const Routes = () => {
  return (
    <Router>
      <Private unauthenticated="login">
        <Set wrap={AdminLayout}>
          <Route path="/dashboard" page={DashboardPage} name="dashboard" />
        </Set>
      </Private>
      <Route path="/signup" page={SignupPage} name="signup" />
      <Route notfound page={NotFoundPage} />
      <Route path="/" page={LoginPage} name="login" />
    </Router>
  )
}

My expectation is that I would be redirect to the LoginPage if I try the route “/dashboard”.
But instead the browser just shows a blank page.

What do I need to do?

Thank you for help!

I don’t see anything that stands out.

  1. Maybe try re-ordering things
    <Set wrap={AdminLayout}>
         <Private unauthenticated="login">
            <Route path="/dashboard" page={DashboardPage} name="dashboard" />
  1. Could you post your App.js too?

Hi Patrick, thank you for your help!
Unfortunately re-ordering doesn’t help.
Doing this the AdminLayout (e.g. menu, logo, etc…) is shown but the page itself is still empty.

This is the content of my App.js.

const App = () => (
  <FatalErrorBoundary page={FatalErrorPage}>
    <RedwoodProvider titleTemplate="%PageTitle | %AppTitle">
      <AuthProvider type="dbAuth">
        <RedwoodApolloProvider>
          <Suspense fallback="... is loading">
            <Routes />
          </Suspense>
        </RedwoodApolloProvider>
      </AuthProvider>
    </RedwoodProvider>
  </FatalErrorBoundary>
)

The Suspense-node is from i18next translations to autoload the language files.
Removing it has no effect.

Again, thank you for your help!

Anything in browser’s console when that blank page appears?

Hi!
Thank you all for your help.

Upgrading to RW 0.37.3 solved the problem. Now the app behaves as expected, if not loggedin the user is redirected to the login page.

@callingmedic911:
Unfortunately there were no errors on the console. Anyways, currently it works :crossed_fingers:

1 Like