Closed gdubemendez closed 1 year ago
Yes, I'm working on a fix for this, it will be ready shortly.
I've just released https://github.com/dcblogdev/laravel-microsoft-graph/releases/tag/v3.2.0. the only changes required are updating the listener to the following if you're using the provided listener.
<?php
namespace App\Listeners;
use App\Models\User;
use Dcblogdev\MsGraph\MsGraph;
use Illuminate\Support\Facades\Auth;
class NewMicrosoft365SignInListener
{
public function handle($event)
{
$user = User::firstOrCreate([
'email' => $event->token['info']['mail'],
], [
'name' => $event->token['info']['displayName'],
'email' => $event->token['info']['mail'] ?? $event->token['info']['userPrincipalName'],
'password' => '',
]);
(new MsGraph())->storeToken(
$event->token['accessToken'],
$event->token['refreshToken'],
$event->token['expires'],
$user->id,
$user->email
);
Auth::login($user);
}
}
Also updated the docs to make them more clear.
Every time a new user logs in, it replaced the last users token entry on the database.