Setu-TS
    Preparing search index...

    Function requireAuth

    • Guard that requires authentication.

      Without options an unauthenticated request is answered 401 Problem Details. With signInPage, an unauthenticated browser navigation (see RequireAuthOptions.signInPage) is answered 302 to the sign-in page instead, carrying the requested path and query as returnTo — validated by safeReturnTo, which the application's own login handler should apply again before redirecting back. Every other unauthenticated request keeps the 401.

      Parameters

      Returns MiddlewareFunction

      Middleware function

      When signInPage is not a same-origin absolute path

      app.router.get('/protected', { middleware: [requireAuth()], handler });
      app.router.get('/account', { middleware: [requireAuth({ signInPage: '/login' })], handler });