dimanche 7 juillet 2019

Unauthenticated with the guard (session)

I don't need to use the token to authenticate but I am building REST API. so I made a custom guard to use the session with basic auth. When I try to authenticate from the postman it shows always unauthenticated. When I try to login in 'php artisan tinker' with a 'user instance', it works. My question is

  1. when I login from tinker using 'Auth::login($user)', does it keep the session?

  2. What the authentication is not working from the code provided below.

  3. between api.php and web.php which one is executed first?

  4. when I use postman basic auth. Do I have to provide just normal password like 'admin' or hashed password?

Auth.php


    'api' => [
            'driver' => 'session',
            'provider' => 'users',
        ],


api.php

Route::group(['prefix' => 'v1', 'middleware' => ['auth:admin','admin']], function () {
    Route::get('/users/check', 'v1\UserController@userOnlineStatus');

    Route::resource('/users', v1\UserController::class)->except([
        'create', 'edit'
    ]);
}

web.php


Auth::routes();
Route::get('/{any}', 'SinglePageController@index')->where('any', '.*');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire