1 <?php
2 3 4 5 6
7 class MemberPassword extends DataObject {
8 static $db = array(
9 'Password' => 'Varchar',
10 'Salt' => 'Varchar',
11 'PasswordEncryption' => 'Varchar',
12 );
13
14 static $has_one = array(
15 'Member' => 'Member'
16 );
17
18 static $has_many = array();
19
20 static $many_many = array();
21
22 static $belongs_many_many = array();
23
24 25 26 27
28 static function log($member) {
29 $record = new MemberPassword();
30 $record->MemberID = $member->ID;
31 $record->Password = $member->Password;
32 $record->PasswordEncryption = $member->PasswordEncryption;
33 $record->Salt = $member->Salt;
34 $record->write();
35 }
36
37 38 39 40 41 42 43
44 function checkPassword($password) {
45 $spec = Security::encrypt_password(
46 $password,
47 $this->Salt,
48 $this->PasswordEncryption
49 );
50 $e = $spec['encryptor'];
51 return $e->compare($this->Password, $spec['password']);
52 }
53
54
55 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-