passport-multiauth icon indicating copy to clipboard operation
passport-multiauth copied to clipboard

Unauthenticated

Open fauzanmh opened this issue 6 years ago • 12 comments

login with custom provider is successfull, but always Unauthenticated when user Route::group(['middleware' => 'multiauth:member'], function(){ Route::get('/member', function($request){ $request->user(); }); })`

this my auth.php Screenshot_31

this my model Screenshot_32

this my Kernel Screenshot_33

and this my route api Screenshot_34

can you help me for solution this issue? and sorry for my english

fauzanmh avatar Jun 26 '19 07:06 fauzanmh

I'm encountering the same issue

majebry avatar Jul 04 '19 09:07 majebry

Please, let me know your laravel, passport and passport-multiauth versions.

sfelix-martins avatar Jul 04 '19 12:07 sfelix-martins

  • Updating laravel/framework (v5.8.0 => v5.8.27): Downloading (100%)
  • Updating laravel/passport (v7.2.0 => v7.3.1): Downloading (100%)
  • Updating smartins/passport-multiauth (v4.0.0 => v4.1.0): Downloading (100%)

majebry avatar Jul 04 '19 13:07 majebry

In the version 4.0.0 of the package all works fine?

sfelix-martins avatar Jul 04 '19 16:07 sfelix-martins

Unfortunately not, the issue appeared before and after the update.

I just noticed that locally it's working fine, but seems that the issue related to the hosting?

majebry avatar Jul 04 '19 22:07 majebry

same me, i have error, i'm using laravel 5.7 and version 4.0.0.

trantung avatar Jul 26 '19 03:07 trantung

The same for me... Laravel 5.8.33 + Passport 7.4.0 + Passport Multi-Auth 4.1.0

nevedimko avatar Sep 10 '19 20:09 nevedimko

@sfelix-martins : please help me

trantung avatar Sep 12 '19 06:09 trantung

Hi

Please check if the default guard is web on config\auth.php

sfelix-martins avatar Nov 09 '19 02:11 sfelix-martins

Hi,

I also having the same issue. I already follow everything even tried to Install everything from the very beginning. Can you suggest a solution on this? I try to change the Routing to this

Route::group(['middleware'=>['auth:externals']],function() { Route::post('/bl/transaction', 'Api\Marketplace\WarungBukalapakController@acceptTransaction'); Route::get('/bl/transaction/{bl_transaction_id}', 'Api\Marketplace\WarungBukalapakController@checkTransaction'); });

Now it with the token provided it can access it. But if I use another token with different provider it still let through. Please need help.

ferdyantorand avatar Jan 20 '20 08:01 ferdyantorand

Hi I was have the same problem but I solved it by check the provider in login function If the provider = customer I login with model Customer and generate access-token from Customer model if the provider = admin I deal with Admin Model and so on . and I check if customer access-token can access admin route nothing happens customer access-token can only access customer routes

 public function login()
    {
        if (request('provider')==='vistor') {
            if (Customer::where('email', request('email'))->count()>0) {
                Customer::where('email', request('email'))->first()->password;
                if (Hash::check(request('password'), Customer::where('email', request('email'))->first()->password)) {
                    $user =  Customer::where('email', request('email'))->first();
                    $success['token'] =  $user->createToken('MyApp')-> accessToken;
                    return response()->json(['success' => $success], $this-> successStatus);
                } else {
                    return response()->json(['error'=>'Unauthorised'], 401);
                }
            } else {
                return response()->json(['error'=>'Unauthorised'], 401);
            }
        } elseif (Admin::where('email', request('email'))->count()>0) {
            Admin::where('email', request('email'))->first()->password;
            if (Hash::check(request('password'), Admin::where('email', request('email'))->first()->password)) {
                $user =  Admin::where('email', request('email'))->first();
                $success['token'] =  $user->createToken('MyApp')-> accessToken;
                return response()->json(['success' => $success], $this-> successStatus);
            } else {
                return response()->json(['error'=>'Unauthorised'], 401);
            }
        } else {
            return response()->json(['error'=>'Unauthorised'], 401);
        }
    }

My Route

Route::group(['middleware' => 'auth:customer'], function(){
    Route::post('getaction', 'API\AuthApiController@action');


});
Route::group(['middleware' => 'auth:admin'], function(){


Route::post('getitem', 'API\AuthApiController@items');


});

ycit-alzuabiri avatar May 02 '20 23:05 ycit-alzuabiri

I have the same problem, this issue has answer?

negothales97 avatar May 26 '20 15:05 negothales97