_user = AdminUser::findByPasswordResetToken($token); if (! $this->_user) { throw new InvalidParamException('Wrong password reset token.'); } parent::__construct($config); } /** * @inheritdoc */ public function rules() { return [ ['password', 'required'], ['password', 'string', 'min' => 6], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'password' => yii::t('app', 'Password'), ]; } /** * Resets password. * * @return boolean if password was reset. */ public function resetPassword() { $user = $this->_user; $user->setPassword($this->password); $user->removePasswordResetToken(); Event::off(BaseActiveRecord::className(), BaseActiveRecord::EVENT_AFTER_UPDATE); return $user->save(false); } }