default
[ class tree: default ] [ index: default ] [ all elements ]

Source for file MemberPassword.php

Documentation is available at MemberPassword.php

  1. <?php
  2.  
  3. /**
  4.  * Keep track of users' previous passwords, so that we can check that new passwords aren't changed back to old ones.
  5.  */
  6. class MemberPassword extends DataObject {
  7.     static $db array(
  8.         'Password' => 'Varchar',
  9.         'Salt' => 'Varchar',
  10.         'PasswordEncryption' => 'Varchar',
  11.     );
  12.     
  13.     static $has_one array(
  14.         'Member' => 'Member',
  15.     );
  16.     
  17.     /**
  18.      * Log a password change from the given member.
  19.      * Call MemberPassword::log($this) from within Member whenever the password is changed.
  20.      */
  21.     static function log($member{
  22.         $record new MemberPassword();
  23.         $record->MemberID $member->ID;
  24.         $record->Password $member->Password;
  25.         $record->PasswordEncryption $member->PasswordEncryption;
  26.         $record->Salt $member->Salt;
  27.         $record->write();
  28.     }
  29.     
  30.     /**
  31.      * Check if the given password is the same as the one stored in this record
  32.      */    
  33.     function checkPassword($password{
  34.         $encryption_details Security::encrypt_password($password$this->Salt$this->PasswordEncryption);
  35.         return ($this->Password === $encryption_details['password']);
  36.     }
  37.     
  38.     
  39. }

blog comments powered by Disqus
Documentation generated on Tue, 13 May 2008 06:35:29 +1200 by phpDocumentor 1.3.2