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(); }
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; }
/** * 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'))); }
/** * 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)); }