jedireza / aqua

:bulb: A website and user system starter
https://jedireza.github.io/aqua/
MIT License
1.38k stars 356 forks source link

After user login, homepage doesn't show login session? #232

Closed jacogreyling closed 7 years ago

jacogreyling commented 7 years ago

When you create an user and you login you get the 'My account' page. When you then navigate to '/' you get the homepage BUT it tells you that you're signed out. (Or at least it shows the 'Sign In' link in the top right hand corner.) Is this intended behaviour? I would think that keeping the user 'logged in' irrespective of the page viewed should be the right behaviour. Only if the user explicitly log out or close their browser session should it go back to 'Sign In'.

jedireza commented 7 years ago

When you create an user and you login you get the 'My account' page. When you then navigate to '/' you get the homepage BUT it tells you that you're signed out. (Or at least it shows the 'Sign In' link in the top right hand corner.)

Correct, you're not logged out.

Is this intended behaviour? I would think that keeping the user 'logged in' irrespective of the page viewed should be the right behaviour. Only if the user explicitly log out or close their browser session should it go back to 'Sign In'.

Intended as in designed to stay like this, no. Intended as in up to you to customize/change, yes.

You'll notice that if you click on the "Sign in" tab when you're logged in, it redirects you back to your account or the admin depending on your role.

Here we call the getUserCreds action. Which has a handler that redirects the user if they're logged in: https://github.com/jedireza/aqua/blob/4e7cb75253a04e870b73e61a73842f896ecf983e/client/pages/main/login/home/index.jsx#L22

And here is the action handler that checks the response and does the redirect: https://github.com/jedireza/aqua/blob/4e7cb75253a04e870b73e61a73842f896ecf983e/client/pages/main/login/actions.js#L36-L53

You could add logic to your main app, navbar, etc..., (using a shared store maybe) that stores the response of this action and shows the username instead of "Sign in" for example.