Question: function for non authenticated request instead redirectURL
Pasupathi-Rajamanickam opened this issue · 3 comments
I have a different authentication mechanism where I don't want to send user to redirectURL
rather I want to check incoming request header and allow users to continue. Basically if there is a way to provide function for redirectURL. Is there a way to do that?
redirectTo
can be a function, yes. It receives the request
as an argument. Note that it will only be called if the request is unauthenticated (user is logged out). And it is expected to return a string (the URL to redirect to). if you return false
, the server will return a 401 error telling the user they are unauthenticated.
You could instead use optional
auth mode and do your business logic in the route handler. In that case, you would want to check request.auth.isAuthenticated
to see if the user is logged in. And you can do whatever redirects you want in the handler.
Thanks @sholladay
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.