laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.33k stars 10.96k forks source link

Laravel 5.7 multiple authentication api route problem #26762

Closed fkomaralp closed 5 years ago

fkomaralp commented 5 years ago

Firstly hi all and sorry my poor english.

I have a problem on my laravel project.

I have multiple authentication on my laravel project. And also I have 3 guards. Login screens works perfecly with web.php.

I just want to write an api resource. I want to if any user logined to system with web,sube_admin and admin guards return an result; this api must be accessible for all users.

Firstly i'm logined with admin guard.

If I write this in to web.php

Route::middleware('auth_api_json:admin,sube_admin,web')->group(function(){
    Route::get('/iller', function (Request $request) {

        dd(auth()->guard("admin")->check());

    });

});

And if I go to localhost:8000/iller address, this code is returns true.

If I write bellow code on my api.php file

Route::middleware('auth_api_json:admin,sube_admin,web')->group(function(){
    Route::get('/iller', function (Request $request) {

        dd(auth()->guard("admin")->check());

    });

});

I need to go now to localhost:8000/api/iller address, after that I see in my results is false.

I just want to write my code perfectly, I want to use my api.php file and I want to use /api/ on my address bar.

And here is my auth_api_json Middleware file source.

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Api extends Middleware
{

}
driesvints commented 5 years ago

Hi there,

Looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library. If you have a question on how to use functionality provided by this repo you can try one of the following channels: