Get rid of validation on login page and show error upon failed authentication attempt
MODIFY
app/Http/Controllers/LoginController.php
app/Http/Controllers/LoginController.php
@@ -11,24 +11,16 @@ class LoginController extends Controller {
}
public function store(Request $request) {
- $this->validate($request, [
- 'email' => 'required|email',
- 'password' => 'required'
- ]);
-
- $email = $request->input('email');
- $password = $request->input('password');
-
if (Auth::attempt([
- 'email' => $email,
- 'password' => $password
+ 'email' => $request->input('email'),
+ 'password' => $request->input('password')
])) {
return redirect()->route('dashboard');
} else {
return redirect()
->route('login')
- ->withErrors([
- 'credentials' => 'There\'s no user with that email address/password'
+ ->with([
+ 'status' => 'Failed to login'
]);
}
}

MODIFY
resources/views/login.blade.php
resources/views/login.blade.php
@section('body')
<div class="wrapper narrow spacing-top-large spacing-bottom-large">
+ @if (session('status'))
+ <div style="
+ padding: 10px;
+ margin-bottom: 20px;
+ text-align: center;
+ color: #FFF;
+ background: #FE7C4D;
+ border-radius: 5px;
+ ">{{ session('status') }}</div>
+ @endif
<div class="box">
<div class="section">
<div class="row">

Get rid of validation on login page and show error upon failed authentication attempt