samedi 30 novembre 2019

Authentication redirect route

can you help me how to create if isadmin is true it will be redirected to admin page, else home page.

AuthController

public function postLogin(Request $request){
       if(!auth()->attempt(['email' => $request->email, 'password' => $request->password])){
        return redirect()->back();
       }
       return redirect()->route('home');
    }

the main reason's maybe because this

return redirect()->route('home');

when tried change to ('admin') it successfully redirecting.

when i tried to add

protected function authenticated(\Illuminate\Http\Request $request, $user)
    {
        if( $user->isadmin){
           return redirect('admin');
        }
        return redirect('home');
    }

it didnt works too



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire