mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
3936bc516b
commit
a597942984
@ -684,6 +684,22 @@ class ViewableData extends Object implements Iterator {
|
||||
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.
|
||||
* Can be used to implement security-specific sections within templates
|
||||
|
Loading…
Reference in New Issue
Block a user