我希望仅在访问者未登录时才能使用我的注册页面。
我想用Security.Authenticated
方法实现这一目标。怎么做?
答案 0 :(得分:1)
可以定义自己的Action类型,而不是使用Secured trait?这是未经测试的......
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.
}