MemberStack.io

Should a logged in user be able to see the login page?

Hi everyone!

I am experimenting with my setup and I noticed that a logged in user can see the /login and /signup pages. Is it possible to redirect them to their user-specific dashboard if they are already logged in?

Thanks!

For /login, I noticed that it redirects successfully when I click a “Login” link. But not if I type /login in the browser.

1 Like

Looks like placing the following code by @Josh-Lopez in both /login and /signup pages worked here too:

<script>
MemberStack.onReady.then(function(member) {   
  if (member.loggedIn) {
     var memberId = member.id;
     window.location.replace("/investors-id/" + memberId);
  }
})
</script>

:+1:

2 Likes

Awesome! Thanks for sharing :grin:

Sorry! Code noob here. Where should I place this code ? In the head or body ?

Thank you! :slight_smile:

Nevermind. I figured it out with some trial and error. If someone is looking for it in the future, use this and place it in the body tag of the page :slight_smile:

<script>
MemberStack.onReady.then(function(member) {   
  if (member.loggedIn) {
     var memberId = member.id;
     window.location.replace('URL of the page you want the user to be redirected to goes here');
  }
})
</script>