user = User::findByPasswordResetToken($token); if (!$this->user) { throw new InvalidArgumentException('Wrong password reset token.'); } parent::__construct($config); } /** * @inheritdoc */ public function rules(): array { return [ ['password', 'required'], ['password', 'string', 'min' => 6], ]; } /** * @return bool * @throws Exception */ public function resetPassword(): bool { $user = $this->user; $user->setPassword($this->password); $user->removePasswordResetToken(); return $user->save(false); } }