简体   繁体   中英

scala play! page only for new users

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?

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.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM