_user = User::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 [ 'username' => '验证码', 'name' => '姓名', 'email' => '电子邮件', 'password' => '密码', 'body' => '内容', ]; } /** * Resets password. * * @return bool if password was reset. */ public function resetPassword() { $user = $this->_user; $user->setPassword($this->password); $user->removePasswordResetToken(); return $user->save(false); } }