/** * Changes the password for an account. * * @return boolean whether the password was changed. */ public function changePassword() { if ($this->validate()) { $this->account->password = $this->password; if ($this->account->save()) { $this->createHistoryEntry($this->account); return true; } foreach ($this->account->getErrors(Module::getInstance()->passwordAttribute) as $error) { $this->addError('password', $error); } } return false; }
/** * @return \yii\db\ActiveQuery */ public function getAccount() { return $this->hasOne(Account::className(), ['id' => 'accountId']); }
/** * Initializes the class map. */ protected function initClassMap() { $this->classMap = ArrayHelper::merge([self::CLASS_ACCOUNT => Account::className(), self::CLASS_TOKEN => AccountToken::className(), self::CLASS_PROVIDER => AccountProvider::className(), self::CLASS_LOGIN_HISTORY => AccountLoginHistory::className(), self::CLASS_PASSWORD_HISTORY => AccountPasswordHistory::className(), self::CLASS_LOGIN_FORM => LoginForm::className(), self::CLASS_PASSWORD_FORM => PasswordForm::className(), self::CLASS_SIGNUP_FORM => SignupForm::className(), self::CLASS_CONNECT_FORM => ConnectForm::className(), self::CLASS_FORGOT_PASSWORD_FORM => ForgotPasswordForm::className(), self::CLASS_WEB_USER => User::className(), self::CLASS_CAPTCHA => Captcha::className(), self::CLASS_CAPTCHA_ACTION => CaptchaAction::className(), self::CLASS_PASSWORD_BEHAVIOR => PasswordAttributeBehavior::className(), self::CLASS_PASSWORD_VALIDATOR => PasswordStrengthValidator::className()], $this->classMap); }
/** * @inheritdoc */ public function rules() { return [[['email', 'username'], 'required'], ['username', 'string', 'min' => Module::getParam(Module::PARAM_MIN_USERNAME_LENGTH)], ['email', 'email'], [['username', 'email'], 'unique', 'targetClass' => Account::className()]]; }