playframework/playframework — pull request #2511 by tsuyoshizawa (2014-03-20 06:51:30+00:00)
Title: Add customizable CSRF error handling

CSRF error will never occur rarely in normal operation to user.
However, there is a possiblity accident. For example, reloading page again after user posted data.

CSRF module returns only text message to user if the module found CSRF token error.
However, I think almost users can't understand the message what should I do next.

> Invalid token found in form body

Application would like to redirect to signed in page.
In another case, application may would like to throw Exception for handling on Global object.

My PR is able to customize the error handling on application.

```
private def checkFailedResult(msg: String): SimpleResult = throw new CsrfException(msg)

def post = CSRFFilter(checkFailedResult = checkFailedResult) { Action {

}}
```