Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/Listeners/Auth/UpdateUsersTimezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Laravel\Passport\Events\AccessTokenCreated;
use Torann\GeoIP\Location;

use App\Models\User; //added this to allow us use the User model below

class UpdateUsersTimezone
{
/**
Expand All @@ -27,9 +29,16 @@ public function handle($event)
* making this listener be called again.
*/
if ($event instanceof AccessTokenCreated) {
Auth::loginUsingId($event->userId);

return;
//Auth::loginUsingId($event->userId); //loginUsingId does not exist in Laravel Passport's AccessTokenCreated event

/*
Passport's AccessTokenCreated event indicates a login has occured and therefore when using Passport (for API), we do
not really need the login event below. Since that login event merely returns the logged in user's user object, we
might as well return the user object here. To do that, we have add "use App\Models\User" at the header section of this
page.
*/
$user = User::find($event->userId);
//return; //leaving this causes $user to return null
}

/**
Expand Down