i got error while login, the situation is that i'm creating a multi auth system in laravel, i have one user which is admin and one user which is subadmin, the admin login correctly but when i try to login subadmin it give an error "undefined index", i checked all the answers that are related to "undefined index" but my problem is not solved. i check the my form properly, i checked my login() method, i check the attempt() method but no positive result. please help me. thanks
login method
public function login(Request $request)
{
// Validate the form data
$this->validate($request, [ // $this is use to access the members of current cls.
'email' => 'required|email',
'password' => 'required'
]);
if(!Auth::guard('subadmin')->attempt(['status' => 1]))
{
session()->flash('status', 'Your account is not activated. Please contact to the main branch');
return view('frontend.agent.showRegisteredMsg');
}
//Attempt to log the user in
if(Auth::guard('subadmin')->attempt(['email' => $request->email, 'password'=> $request->password], $request->remember))
{
return redirect()->intended(route('subadmin.dashboard'));
}
//if unsuccessfull
return redirect()->back()->withInput($request->only('email', 'remember'));
}
login form
<form action="" method="post">
@csrf
<div class="form-group">
<label class="sr-only"></label>
<input class="form-control trans" type="email" placeholder="Email" name="email">
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong></strong>
</span>
@endif
</div>
<div class="form-group">
<label class="sr-only"></label>
<input class="form-control trans" type="password" placeholder="Password" name="password">
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong></strong>
</span>
@endif
</div>
<div class="checkbox text-left">
<label>
<input type="checkbox" name="remember"> Remember Password
</label>
</div>
<input type="submit" class="btn btn-block btn-primary" value="Login">
<div class="bg-light animation flipInX">
<a href="" style="color:red">Forgot Password?</a>
</div>
</form>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire