Added $SecurityID for templates

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47839 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-01-10 20:47:50 +00:00
parent 3936bc516b
commit a597942984

View File

@ -683,6 +683,22 @@ class ViewableData extends Object implements Iterator {
function CurrentMember() {
return Member::currentUser();
}
/**
* Returns the Security ID.
* This is used to prevent CRSF attacks in forms.
* @return int
*/
function SecurityID() {
if(Session::get('SecurityID')) {
$securityID = Session::get('SecurityID');
} else {
$securityID = rand();
Session::set('SecurityID', $securityID);
}
return $securityID;
}
/**
* Checks if the current user has the given permission.