Guest User

Untitled

a guest
May 7th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2. class User extends fActiveRecord
  3. {
  4.    
  5.     protected function configure(){
  6.        
  7.         fORMValidation::addRequiredRule($this, array('first_name', 'last_name', 'pharmacy_name', 'pharmacy_zip', 'email'));
  8.         fORMColumn::configureEmailColumn($this, 'email');
  9.        
  10.         fORM::registerHookCallback($this, 'post::validate()', 'User::validatePassword');
  11.        
  12.     }
  13.    
  14.     static public function validatePassword($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages){
  15.         // If a new password was set, it came through the request and does not match the field password_confirm, add an error message
  16.         if (fActiveRecord::hasOld($old_values, 'password') && fRequest::get('password') && fRequest::get('password') != fRequest::get('password_confirm')) {
  17.             $validation_messages[] = 'Password: The value entered does not match Password Confirmation';
  18.         }
  19.     }
  20.    
  21.     public function setPassword($pass){
  22.         $this->set('password', fCryptography::hashPassword($pass));
  23.     }
  24.     public function getPassword(){
  25.         $pass = $this->values['password'];
  26.         return fCryptography::checkPasswordHash($pass);
  27.     }
  28.    
  29. }
Add Comment
Please, Sign In to add comment