Question

I am testing Play framework 2.2.2. There is a helper for user authentication and seems to be simple to implement it. But if I need to hide some menus or other content from unregistered users - how can I do it?

I am thinking about if-blocks:

@if(...) {
  <h1>Content for registered users only</h1>
} else {
  <h1>Register to see this content</h1>
}

but what will be in the condition block? Have anybody an example?

Was it helpful?

Solution

Consider using Deadbolt-2 it's dedicated for this job, it allows to show (or hide) content in views depending on logging state but also by roles and permitions. Also incorporates access control for controller and/or actions.

Optionally you can also look at Play Authnticate it's full authorization/authentication stack - it also uses Deadbolt for mentioned reasons.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top