It is not clear for me how to handle authentication with LiveView. From some posts here it appears that login form should not be a Liveview in order to set the session variables that can be used by both Liveview and views.
In my application, the user logs in and is redirected to a Liveview. My problem is that if how do I check if the user can display that liveview? In many websites, when a user has no access to a resource, he is redirected to a login page.
I tried to do the same with my liveviews and checked session variables from the mount/2 function in the liveview but redirection is not allowed from that function. Do you have any clues on how this can be cleanly done? I could render something else in the “render” function but since the login view is not a liveview (for the reasons mentionned earlier) I can it to work this way.
I could of course add a big “if” in all of my templates and show a link to the login page if authentication fails but that looks like a ugly solution.
Any hints would be appreciated. Thanks.