Reputation: 749
I want to have my registration page available only when visitor is not logged in.
I'd like to accomplish that with Security.Authenticated
method. How to do that?
Upvotes: 0
Views: 33
Reputation: 31700
Instead of using the Secured trait, maybe define your own Action type? This is untested...
def NotLoggedInAction(f: Request[AnyContent] => Result): Action[AnyContent] = {
Action { request =>
if(isLoggedIn(request)) Redirect(views.html.noneForYou)
else f(request)
}
}
def isLoggedIn(request: Request) = ??? // You implement this
def mustBeSecured = NotLoggedInAction { implicit request =>
// Your application logic here.
}
Upvotes: 1