I like the way this middleware auth functions works, but I don't know how to make this function redirect to some login page when the user is not allowed to access some route. I don't know if I'm making confuse here, but I didn't find it anywhere!
The examples only show the API. You need to set up the authorizer function to respond with unauthorized and a proper status code like 401 if the user is not authorized to access a resource. This is what you catch on the front end, and handle redirects to a login page.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like the way this middleware auth functions works, but I don't know how to make this function redirect to some login page when the user is not allowed to access some route. I don't know if I'm making confuse here, but I didn't find it anywhere!
The examples only show the API. You need to set up the authorizer function to respond with
unauthorized
and a proper status code like401
if the user is not authorized to access a resource. This is what you catch on the front end, and handle redirects to a login page.