vendredi 20 mars 2020

Auth::guard('admin')->user() is NULL in laravel 5.8

I'm trying to return the user logged in but I'm getting null when I dd(Auth::guard('admin')->user() in the login Controller it works but when I try to use it in NiveauController it returns null.

LoginController:

public function VerifierLogin(Request $request)
{

    $this->validate($request, [
        'email'   => 'required|email',
        'password' => 'required|min:6'
    ]);

    if (Auth::guard('enseignant')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) {
        Auth::guard('enseignant')->user();

        return redirect()->intended(route('EnseignantDashboard'));
    }
    if (Auth::guard('superadmin')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) {
        Auth::guard('superadmin')->user();

        return redirect()->intended('/superadmin');

    }
    if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) {
        Auth::guard('admin')->user();

        return redirect()->intended('/admin');
    }

    return back()->withInput($request->only('email', 'remember'))->with('error');
     }

NiveauController:

 public function showListNiveaux()
{


    $admin=Auth::guard('admin')->user();

    dd( $admin);

   $niveaux = DB::table('niveaux')->where('id_etablissement',$admin->id_etablissement);

    return view('Niveau:index',compact($niveaux));
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dhX50v
via IFTTT

Aucun commentaire:

Enregistrer un commentaire