Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel multi auth custom guard wont log in #1

Open
MohamedAlQadeery opened this issue Sep 11, 2018 · 0 comments
Open

Laravel multi auth custom guard wont log in #1

MohamedAlQadeery opened this issue Sep 11, 2018 · 0 comments

Comments

@MohamedAlQadeery
Copy link
Owner

MohamedAlQadeery commented Sep 11, 2018

i make multi guard on my project just for testing both guard have the same persmissions but the other guard wont login

here is the auth.php

guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
    'worker' => [
        'driver' => 'session',
        'provider' => 'workers',
    ],
    'api' => [
        'driver' => 'token',
        'provider' => 'users',
    ],
],
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
    'workers' => [
        'driver' => 'eloquent',
        'model' => App\Worker::class,
    ],

and here is the loginController btw the loginattempt is working i checked it

 protected $redirectTo = '/home';

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest')->except('logout');
}

protected function attemptLogin(Request $request)
{
    if(Auth::guard('web')->attempt($this->credentials($request), $request->filled('remember')))
        return true;
    elseif(Auth::guard('worker')->attempt($this->credentials($request),$request->filled('remember'))){
        return true;
    }
}

and here is my web routes

Route::get('/', ['as' => 'album.index', 'uses' => 'AlbumController@index']);
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');

Route::group(['middleware' => 'auth'], function () {
    Route::get('logout', 'Controller@customLogout')->name('customLogout');

    Route::group(['prefix' => 'album'], function () {
        Route::get('/showAllAlbums', ['as' => 'album.showAllAlbums', 'uses' => 'AlbumController@showAllAlbums']);
        Route::get('create', ['as' => 'album.create', 'uses' => 'AlbumController@create']);
        Route::post('create', ['as' => 'album.store', 'uses' => 'AlbumController@store']);
        Route::get('/{id}', ['as' => 'album.show', 'uses' => 'AlbumController@show']);
        Route::get('delete/{id}', ['as' => 'album.destroy', 'uses' => 'AlbumController@destroy']);

        // upload Photos Routes
        Route::get('/uploadPhoto/{id}', ['as' => 'photo.create', 'uses' => 'PhotoController@create']);
        Route::post('/uploadPhoto', ['as' => 'photo.store', 'uses' => 'PhotoController@store']);

    });

    Route::group(['prefix' => 'photo'], function () {
        Route::get('/{id}', ['as' => 'photo.show', 'uses' => 'PhotoController@show']);
        Route::get('delete/{id}', ['as' => 'photo.destroy', 'uses' => 'PhotoController@destroy']);
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant