You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manabu Nakamura edited this page May 11, 2013
·
2 revisions
Changing the display depending on whether the user is logged in
If you want to display the application's index differently to non-logged-in users
and logged-in users, you can use OptionalAuthElement insted of AuthElement:
objectApplicationextendsControllerwithOptionalAuthElementwithAuthConfigImpl {
// maybeUser is an instance of `Option[User]`.// `OptionalAuthElement` dont need `AuthorityKey`defindex=StackAction { implicit request =>valmaybeUser:Option[User] = loggedIn
valuser:User= maybeUser.getOrElse(GuestUser)
Ok(html.index(user))
}
}