简体   繁体   中英

Using multiple Auth in Laravel 5.3?

I'm creating a RESTApi in laravel 5.3 along with my API I also make a web application for admin use. In this web app I'm using laravel's easy auth (php artisan make:auth) which work just fine, but before starting up my web app I use JWT auth for my RESTApi. Now when I try to get a user from a JWToken with this call

 Auth:user() 

It does not return the right user, it returns the user in my 'Admin' model. I have two model, User and Admin, where User is used for my API and Admin is for my web/admin app. Is there a way I can separate these two authentication so that I use easy auth for 'Admin' and JWT for 'User'?

In each my API controller I have this middleware in the constructor:

public function __construct()
{

    $this->middleware('jwt.auth');
}

You can try my package for multi auth in laravel 5.3. https://github.com/Hesto/multi-auth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM