sfelix-martins / passport-multiauth

Add support to multi-authentication to Laravel Passport
MIT License
288 stars 51 forks source link

It will be nice to see an implementation with a frontend #29

Closed nicolasflorth closed 6 years ago

nicolasflorth commented 6 years ago

I get stuck when I need to use this part

// `api` guard on end of guards separated by comma
Route::group(['middleware' => ['api', 'auth:admin,api']], function () {
    Route::get('/admin', function ($request) {
        // Passing `api` guard to `$request->user()` method
        // The instance of user authenticated (Admin or User in this case) will be returned
        return $request->user('api');
    });
});

If I need to to the Registration, like

Route::group(['middleware' => ['api', 'auth:crm_user'],
            'prefix' => 'admin',
        ], function() {
    Route::post('register', 'Api\Auth\RegisterController@register');
    Route::post('login', 'Auth\LoginController@login');
});

I am lost.... It will be really nice to see an implementation with a frontend. Maybe somebody can share one. Regards, Nick

sfelix-martins commented 6 years ago

Hi Nicolas.

You can call your controller normally.

What I wanted to show is how you can get the user's logged in according to their guards using the Illuminate\Http\Request or Illuminate\Support\Facades\Auth.

Regarding the error Class SMartins\\PassportMultiauth\\Http\\Middleware\\MultiAuthenticate does not exist, you probably followed the dev-master instructions and downloaded version 1.0.

To use "dev-master" version you should run composer require smartins/passport-multiauth:dev-master. Don't forget that add to your composer.json the options "prefer-stable": true and "minimum-stability": "dev".

If you want continue using the stable version (1.0) follow this intructions.

I hope it helps!

Any doubt I am available.

Regards, Samuel.