Open gswy opened 1 year ago
auth('app')->loginUsingId($user->id);
You can open a new PR to help with that, lately, I'm very busy. Otherwise, I'll take a look at it by myself.
I have customized the user verification process
Please provide more details:
thanks!
You can use tokenById method.
Example:
auth('app')->tokenById($user->id);
You can use tokenById method.
This does something else: it generates a new token.
auth('app')->loginUsingId($user->id);
You can't use loginUsingId
on a API guard.
loginUsingId is from the StatefulGuard contract, but the whole point of an JWT/API token is that it's stateless.
The \PHPOpenSourceSaver\JWTAuth\JWTGuard
is a regular \Illuminate\Contracts\Auth\Guard and hence only provides the methods on the contract.
What you can do is call ->setUser()
and provide your own user.
But everything else it not meant to be here.
IMHO this issue can be closed.
This does something else: it generates a new token.
The issue creator says he wants to use the user's unique ID for login which I assume he wants to generate a new token based on that ID. That's why I answered he could use the tokenById method in that case.
In \PHPOpenSourceSaver\JWTAuth\JWTGuard there is already a method (tokenById) derived from \Tymon\JWTAuth\JWTGuard that can be used.
https://jwt-auth.readthedocs.io/en/develop/auth-guard/#tokenbyid
Summary
I have customized the user verification process. At this time, I use the user's unique identifier to log in, and it is prompted that there is no such method.