Reputation: 11
Please am trying to authenticate user credentials using sentinel but the code does not seem to work.
Please am trying to authenticate user credentials using sentinel but the code does not seem to work.
Any help please.
public function login(Request $request){
/*
return $request->all();
gives me
{"_token":"cUPoDbVgoRBojkMS0J0kqOrqQttiDFqveOjPx6eh",
"email":"[email protected]","p
assword":"123456"}
*/
try {
if(Sentinel::Authenticate($request->all())){
if(Sentinel::check()){
$slug = Sentinel::getUser()->roles()->first()->slug;
$notification = array(
'message' => 'Welcome Back!',
'alert-type' => 'success'
);
if($slug == 'admin'){
return redirect('dashboard/admin')->with($notification);
}
elseif ($slug == 'manager') {
return redirect('dashboard/manager')->with($notification);
}
}
}
else{
$notification = array(
'message' => 'Invalid credentials',
'alert-type' => 'error'
);
return redirect()->back()->with($notification);
}
} catch (ThrottlingException $e) {
$delay = $e->getDelay();
$notification = array(
'message' => 'You are suspended temporary',
'alert-type' => 'error'
);
return redirect()->back()->with($notification);
}catch (NotActivatedException $e) {
$notification = array(
'message' => 'You accout is not Activated yet',
'alert-type' => 'error'
);
return redirect()->back()->with($notification);
}
}
Am using laravel 5.5 and sentinel 2.0
Upvotes: 1
Views: 349