Level 2
Problem has solved
3 likes
I use laravel ui for authentication. Now, I want to custom login where only the admin can log in, otherwise, the user will be redirected to the user's login page. In the user's table one column name "is_admin". If is_admin == 1 then returns to admin panel otherwise return to user's login page. Here is my custom login method
public function adminAuth(Request $request) {
$request->validate([
'email' => 'required',
'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
// what goes here?
}
return redirect()->back()->with('error', 'Oppes! You have entered invalid credentials');
}
Now, How to do that what I want?
@ihprince Just apply a condition insider if.
if (Auth::attempt($credentials)) {
if(Auth::user()->is_admin !== 1){
// Now redirect to the user's login page
}
// Now redirect to the admin panel
}
Please or to participate in this conversation.