I'm currently creating a custom Laravel authentication but I'm struggling with the login form, it keeps saying that it did not recognize the email address. But I'm sure that the email address is already in the database.
Here's my code in Controller:
function check(Request $request){
$request->validate([
'email'=>'required|email',
'password'=>'required|min:6|max:16',
]);
$userInfo = Admin::where('email', '=', $request->email)->first();
if($userInfo){
return back()->with('fail', 'We do not recognize your email address');
}
else {
if(Hash::check($request->password, $userInfo->passsword)){
$request->session()->put('LoggedUser', $userInfo->id);
return redirect('admin/dashboard');
}
else {
return back()->with('fail', 'Incorrect password');
}
}
}
And here's my code in login form blade:
<form action="{{ route('auth.check') }}" class="log-form" method="post">
@if(Session::get('fail'))
<div class="alert-danger">
{{ Session::get('fail') }}
</div>
@endif
@csrf
<div class="name">
<label>Email Address</label><br>
<input type="text" id="email" name="email" value="{{ old('email') }}"><br>
</div>
<span class="text-danger">
@error('email') {{ $message }} @enderror
</span>
<div class="password">
<label>Password</label><br>
<input type="password" id="pass" name="password" value="{{ old('password') }}"><br>
</div>
<span class="text-danger">
@error('password') {{ $message }} @enderror
</span>
<br><br>
<input type="submit" value="LOG IN" class="log-sub">
</form>
What is my mistake here?