Redirection from server based on user authentication

Hey WeWeb community, I am facing an issue in finding a way to authenticate the user (whether he is logged in or not) directly on the server before landing on the login page to redirect him to dashboard.

Can you suggest on how we can solve this problem. Is there some sort of server logic that we can execute for this or a middleware?

Thanks

Hi @Inder :wave:

What backend are you using?

If you’re using a native integration with one of our auth plugins, you could have the dashboard as your homepage. When users land on that page, if they are not logged in, they would be redirected to the page you configured in the authentication plugin (most likely the Login page in your case).

Alternatively, you could have a workflow on page load that calls the user endpoint. If the user is not logged in, you can react to the error message to redirect the user to the login page.

Does that make sense?

Hey @Joyce. Thanks for reaching out.

But in the second approach, the workflow executes after the login is painted to the DOM which we don’t want. We want to user to directly go to dashboard from the server itself. (redirection from server only) since cookies are sharable so we thought this could be done from server too.

I can try the first approach for the same. Thanks for the response.

1 Like