add a method to Action to check session token

This commit is contained in:
Evan Prodromou 2009-11-07 18:51:57 -05:00
parent 5cd385fe4f
commit 31bbdacbf3

View File

@ -1101,4 +1101,22 @@ class Action extends HTMLOutputter // lawsuit
{
return Design::siteDesign();
}
/**
* Check the session token.
*
* Checks that the current form has the correct session token,
* and throw an exception if it does not.
*
* @return void
*/
function checkSessionToken()
{
// CSRF protection
$token = $this->trimmed('token');
if (empty($token) || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token.'));
}
}
}