1
0
mirror of https://github.com/silverstripe/silverstripe-framework synced 2024-10-22 12:05:37 +00:00
Ingo Schommer 3334eafcb1 API Marked statics private, use Config API instead ()
See "Static configuration properties are now immutable, you must use Config API." in the 3.1 change log for details.
2013-03-24 17:20:53 +01:00

51 lines
1.3 KiB
PHP

<?php
/**
* Keep track of users' previous passwords, so that we can check that new passwords aren't changed back to old ones.
* @package framework
* @subpackage security
*/
class MemberPassword extends DataObject {
private static $db = array(
'Password' => 'Varchar(160)',
'Salt' => 'Varchar(50)',
'PasswordEncryption' => 'Varchar(50)',
);
private static $has_one = array(
'Member' => 'Member'
);
private static $has_many = array();
private static $many_many = array();
private static $belongs_many_many = array();
/**
* Log a password change from the given member.
* Call MemberPassword::log($this) from within Member whenever the password is changed.
*/
public static function log($member) {
$record = new MemberPassword();
$record->MemberID = $member->ID;
$record->Password = $member->Password;
$record->PasswordEncryption = $member->PasswordEncryption;
$record->Salt = $member->Salt;
$record->write();
}
/**
* Check if the given password is the same as the one stored in this record.
* See {@link Member->checkPassword()}.
*
* @param String $password Cleartext password
* @return Boolean
*/
public function checkPassword($password) {
$e = PasswordEncryptor::create_for_algorithm($this->PasswordEncryption);
return $e->check($this->Password, $password, $this->Salt, $this->Member());
}
}