如教程中所述,我已经实现了 Secured 特征:
trait Secured {
...
def IsAuthenticated(f: => String => Request[AnyContent] => Result) = Security.Authenticated(username, onUnauthorized) { user =>
Action(request => f(user)(request))
}
...
}
并像这样使用它:
def list = IsAuthenticated { username => _ =>
...
}
现在,我对文件上传有以下定义:
def upload = Action(parse.multipartFormData) { request =>
...
}
是否可以结合 IsAuthenticated 和 parse.multipartFormData 以便我能够在文件上传期间检查用户?