Coder Social home page Coder Social logo

album's Issues

Laravel multi auth custom guard wont log in

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']);
    });
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.