dcblogdev / laravel-microsoft-graph

Laravel package for Microsoft Graph API (Microsoft365)

Home Page:https://dcblog.dev/docs/laravel-microsoft-graph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Token retrieved from DB is not the good one in NewMicrosoft365SignInListener.php

SPepoli opened this issue · comments

Hello,

I just ran into an issue while implementing the library.
The token retrieved from the DB in the listener is not the good one. It seems like it is always the first one because of the line 14 :

$token = MsGraphToken::find($tokenId)->first();

The call to "first()" on "find()" result leads to erroneous behaviour because every user will be authenticated as the first one.
I suggest fixing it like this (adding a check on existence as well, with findOrFail()) :

$token = MsGraphToken::findOrFail($tokenId);