Reputation:
I haven't really used it yet, but I was reading the tutorial here and from what I understand of it, once you annotate to it inside your controller, it completely blocks the user off, and only shows the form.
What I wonder is how you would do to simply hide certain parts of the website. Like show a login form on top when the user is not logged in and show a "profile" button when he is logged in. Disable posting abilities when user is not logged in etc. without hiding everything from a guest.
Would you need to create separate views for these situations, or just check inside the view if the user is logged in? And how would you check to see that, using the secure module?
Upvotes: 1
Views: 4619
Reputation: 4694
The Play secure module authenticate() stores the 'username' in session upon successful login/authentication.
You can make use of this session property in the view to check if user logged in and then change the track accordingly.
#{if session.username }
<!-- You can show users' profile -->
#{/if}
#{else}
<!-- Show login form now. You can create a login template-tag form and call it here. -->
#{/else}
Upvotes: 3