Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User extends fActiveRecord
- {
- protected function configure(){
- fORMValidation::addRequiredRule($this, array('first_name', 'last_name', 'pharmacy_name', 'pharmacy_zip', 'email'));
- fORMColumn::configureEmailColumn($this, 'email');
- fORM::registerHookCallback($this, 'post::validate()', 'User::validatePassword');
- }
- static public function validatePassword($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages){
- // If a new password was set, it came through the request and does not match the field password_confirm, add an error message
- if (fActiveRecord::hasOld($old_values, 'password') && fRequest::get('password') && fRequest::get('password') != fRequest::get('password_confirm')) {
- $validation_messages[] = 'Password: The value entered does not match Password Confirmation';
- }
- }
- public function setPassword($pass){
- $this->set('password', fCryptography::hashPassword($pass));
- }
- public function getPassword(){
- $pass = $this->values['password'];
- return fCryptography::checkPasswordHash($pass);
- }
- }
Add Comment
Please, Sign In to add comment