3

I have successfully loggedin my adminpanel but while I redirect to dashboard after login using middleware it's not working.

login controller

if (Auth::attempt(['username' => $request->email, 'password' => $request->password]))
{
    return redirect('/dashboard');
}

route

Route::group(['middleware' => ['adminAuth']], function () {

    Route::get('/dashboard', 'dashboardController@index');

});

dashboard controller

public function index()
{
    return 'admin dashboard';
}

adminAuthenticate.php Middleware

 public function handle($request, Closure $next)
{
    if(Auth::check() && Auth::user()->role_code == '1'){
        return $next($request);                
    }    
    return abort(404);
}

kernel.php

protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        'adminAuth' => \App\Http\Middleware\adminAuthenticate::class,
    ];

Always it returns '404' page though I have successfully loggedin.

Where is the problem ? anybody help please ? Thanks in advance

Arafat Rahman
  • 993
  • 5
  • 19
  • 46

0 Answers0