Skip to content

Commit

Permalink
Check for session before attempting to invalidate (#750)
Browse files Browse the repository at this point in the history
* Check for session before attempting to invalidate

* Fix formatting, missing a space

* $request->hasSession() not $request->session
  • Loading branch information
inmanturbo authored Apr 7, 2021
1 parent 39d50ec commit e190981
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Http/Livewire/DeleteUserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public function deleteUser(Request $request, DeletesUsers $deleter, StatefulGuar

$auth->logout();

$request->session()->invalidate();
$request->session()->regenerateToken();
if ($request->hasSession()) {
$request->session()->invalidate();
$request->session()->regenerateToken();
}

return redirect('/');
}
Expand Down

2 comments on commit e190981

@Loots-it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this also necessary in src/Http/Controllers/Inertia/CurrentUserController.php @inmanturbo, for inertia?

@inmanturbo
Copy link
Contributor Author

@inmanturbo inmanturbo commented on e190981 Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Loots-it nah works fine with inertia

webpack compiled successfully
Done in 7.38s.
➜  jetstream-demo nano .env
➜  jetstream-demo nano phpunit.xml
➜  jetstream-demo php artisan test                     

   PASS  Tests\Unit\ExampleTest
  ✓ basic test

   WARN  Tests\Feature\ApiTokenPermissionsTest
  - api token permissions can be updated → API support is not enabled.

   PASS  Tests\Feature\AuthenticationTest
  ✓ login screen can be rendered
  ✓ users can authenticate using the login screen
  ✓ users can not authenticate with invalid password

   PASS  Tests\Feature\BrowserSessionsTest
  ✓ other browser sessions can be logged out

   WARN  Tests\Feature\CreateApiTokenTest
  - api tokens can be created → API support is not enabled.

   PASS  Tests\Feature\DeleteAccountTest
  ✓ user accounts can be deleted
  ✓ correct password must be provided before account can be deleted

   WARN  Tests\Feature\DeleteApiTokenTest
  - api tokens can be deleted → API support is not enabled.

   WARN  Tests\Feature\EmailVerificationTest
  - email verification screen can be rendered → Email verification not enabled.
  - email can be verified → Email verification not enabled.
  - email can not verified with invalid hash → Email verification not enabled.

   PASS  Tests\Feature\ExampleTest
  ✓ basic test

   PASS  Tests\Feature\PasswordConfirmationTest
  ✓ confirm password screen can be rendered
  ✓ password can be confirmed
  ✓ password is not confirmed with invalid password

   PASS  Tests\Feature\PasswordResetTest
  ✓ reset password link screen can be rendered
  ✓ reset password link can be requested
  ✓ reset password screen can be rendered
  ✓ password can be reset with valid token

   PASS  Tests\Feature\ProfileInformationTest
  ✓ profile information can be updated

   PASS  Tests\Feature\RegistrationTest
  ✓ registration screen can be rendered
  ✓ new users can register

   PASS  Tests\Feature\TwoFactorAuthenticationSettingsTest
  ✓ two factor authentication can be enabled
  ✓ recovery codes can be regenerated
  ✓ two factor authentication can be disabled

   PASS  Tests\Feature\UpdatePasswordTest
  ✓ password can be updated
  ✓ current password must be correct
  ✓ new passwords must match

  Tests:  6 skipped, 24 passed
  Time:   1.86s

see livewire/livewire#936

which is why I thought to submit #752.
But it's not broken ATM. All args lead to green.

Please sign in to comment.