Tôi muốn có thể sử dụng Trình theo dõi thân máy trên yêu cầu đã được xác thực và tôi đang gặp khó khăn trong việc tìm hiểu cách thực hiện điều đó nếu Xác thực của tôi được thiết lập như ZenTasks thí dụ.Chơi 2.0 Framework, sử dụng BodyParser với yêu cầu được xác thực
phương thức xác thực của tôi,
def IsAuthenticated(f: => String => Request[AnyContent] => Result) = {
Security.Authenticated(username, onUnauthorized) { user =>
Action(request => f(user)(request))
}
}
def HasRole(role: List[String])
(f: => String => Request[AnyContent] => Result) = IsAuthenticated {
user => request => if (role.contains(getRole(user))) {
f(user)(request) // This function returns the result.
} else {
Results.Forbidden
}
}
phương pháp điều khiển của tôi,
def controller = HasRole(List("admin")) { user => _ => {
Action(parse.temporaryFile){ implicit request =>
request.body.moveTo(new File("/tmp/filepath"))
Redirect(routes.home)
}
}
Đây là lỗi tôi nhìn thấy,
[error] found : play.api.mvc.Action[play.api.libs.Files.TemporaryFile]
[error] required: play.api.mvc.Result
[error] Action(parse.temporaryFile){ implicit request =>
[error] ^
Dưới đây là một câu hỏi liên quan: parse.json of authenticated play request
Người này tìm thấy cách giải quyết khác và tôi tin rằng có một ví dụ về tệp tạm thời, nhưng tôi muốn biết làm thế nào (hoặc lý do) những gì tôi đang làm không hoạt động.
Ah, vui vì bạn đã giải quyết nó cuối cùng :) – opyate