Exemplo n.º 1
0
 public function resetPassword($password)
 {
     $hashedPassword = \Yii::$app->security->generatePasswordHash($password);
     $usedPassword = new UserUsedPassword();
     $usedPassword->setAttributes(['user_id' => $this->id, 'password' => $hashedPassword, 'set_on' => date('Y-m-d H:i:s')], false);
     $this->setAttributes(['password' => $hashedPassword, 'password_set_on' => date('Y-m-d H:i:s')], false);
     return $usedPassword->save() && $this->save();
 }
Exemplo n.º 2
0
 public function resetPassword($password)
 {
     if ($this->_id === null) {
         return false;
     }
     if (($record = User::model()->findByPk($this->_id)) !== null) {
         $hashedPassword = User::hashPassword($password);
         $usedPassword = new UserUsedPassword();
         $usedPassword->setAttributes(array('password' => $hashedPassword, 'set_on' => date('Y-m-d H:i:s')));
         return $usedPassword->save() && $record->saveAttributes(array('password' => $hashedPassword, 'password_set_on' => date('Y-m-d H:i:s')));
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Changes the password and updates last password change date.
  * Saves old password so it couldn't be used again.
  * @param string $password new password
  * @return boolean
  */
 public function resetPassword($password)
 {
     if (($record = $this->getActiveRecord()) === null) {
         return false;
     }
     $hashedPassword = User::hashPassword($password);
     $usedPassword = new UserUsedPassword();
     $usedPassword->setAttributes(array('user_id' => $this->_id, 'password' => $hashedPassword, 'set_on' => date('Y-m-d H:i:s')), false);
     return $usedPassword->save() && $record->saveAttributes(array('password' => $hashedPassword, 'password_set_on' => date('Y-m-d H:i:s')));
 }
Exemplo n.º 4
0
 /**
  * Changes the password and updates last password change date.
  * Saves old password so it couldn't be used again.
  * @param string $password new password
  * @return boolean
  */
 public function resetPassword($contrasena)
 {
     if (($record = $this->getActiveRecord()) === null) {
         return false;
     }
     $hashedPassword = Usuarios::model()->hashPassword($contrasena);
     $usedPassword = new UserUsedPassword();
     $usedPassword->setAttributes(array('user_id' => $this->_id, 'password' => $hashedPassword, 'set_on' => date('Y-m-d H:i:s')), false);
     return $usedPassword->save() && $record->saveAttributes(array('contrasena' => $hashedPassword));
 }