How to configure error messages (for example, "These credentials do not match our records." ) That appear when registration / registration fails without having to touch the foundation files? I am looking for a solution and hopefully elegant, at least not touching AuthenticatesAndRegistersUsers and ThrottlesLogins :)
I use AuthController and the forms provided by Laravel after execution:
php artisan make: auth
Controller:
(it only has a constructor and two methods, the rest are based on methods)
protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', ]); } protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); }
the form:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}"> {!! csrf_field() !!} <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <label class="col-md-4 control-label">E-Mail</label> <div class="col-md-6"> <input type="email" class="form-control" name="email" value="{{ old('email') }}" required> @if ($errors->has('email')) <span class="help-block"> <strong>{{ $errors->first('email') }}</strong> </span> @endif </div> </div> <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <label class="col-md-4 control-label">Password</label> <div class="col-md-6"> <input type="password" class="form-control" name="password" required> @if ($errors->has('password')) <span class="help-block"> <strong>{{ $errors->first('password') }}</strong> </span> @endif </div> </div> <div class="form-group"> <div class="col-md-6 col-md-offset-4"> <div class="checkbox"> <label> <input type="checkbox" name="remember"> Remember Me </label> </div> </div> </div> <div class="form-group"> <div class="col-md-6 col-md-offset-4"> <button type="submit" class="btn btn-primary"> <i class="fa fa-btn fa-sign-in"></i>Login </button> <a class="btn btn-link" href="{{ url('/password/reset') }}">Forgot Your Password?</a> </div> </div>
Thanks!
Juan serrats
source share