I've implemented authentication action and put it in the beginning of every method in my controller
def addFile(itemId: Long) = AuthenticatedAction.async(FSBodyParser(itemId)){ request => ...
Then I've implemented my own body parser based on MultipartFormData
def FSBodyParser(itemId:Long): BodyParser[MultipartFormData[Future[BaseFileInfo]]] = {
multipartFormData(Multipart.handleFilePart {
case Multipart.FileInfo(partName, filename, contentType) =>
//println(s"FileInfo($partName, $filename, $contentType)")
getIteratee(1, itemId, filename, contentType)
})
}
And I found that my file is uploaded first and then authentication action check if user is valid. I would like to check user authentication fist and only after that save uploaded file.
Do you have any ideas how to implement this the best way? Probably using Play filters for authentication?