_user = Member::findByPasswordResetToken($token); if (!$this->_user) { throw new UnprocessableEntityHttpException('密码重置令牌错误.'); } parent::__construct($config); } /** * {@inheritdoc} */ public function rules() { return [ ['password', 'required'], ['password', 'string', 'min' => 6], ]; } /** * @return bool * @throws \yii\base\Exception */ public function resetPassword() { $user = $this->_user; $user->setPassword($this->password); $user->removePasswordResetToken(); return $user->save(false); } }