I find myself doing a login from scratch in Laravel, but when I enter it does not give me an error or anything like that, it redirects me to the same login, the code of the form in my view is as follows:
<form method="POST" action="{{ url('/verificar') }}">
{{ csrf_field() }}
<div class="form-group">
<label>Usuario</label>
<input name="usuario" type="text" class="form-control" placeholder="Ingrese su Usuario">
</div>
<div class="form-group">
<label>Contraseña</label>
<input type="password" name="password"class="form-control" placeholder="Ingrese su Contraseña">
</div>
<button type="submit" class="btn btn-black">Ingresar</button>
<button type="submit" class="btn btn-secondary" ><a style="color:#ffffff;"href="{{ route('registro') }}">Registrar</a></button>
</form>
The route with the post method is:
Route::post('/verificar','loginController@login');
and in my controller I have a function which add the following code:
public function login()
{
$credenciales=$this->Validate(request(),
[
'usuario'=>'required|unique:tbl_usuario',
'password'=>'required|min:6'
]);
if (Auth::attempt($credenciales))
{
return view('welcome');
}else{
return back()
->withErrors(['usuario'=>trans('auth.failed')])
->withInput(request(['usuario']));
}
}
The solution that was obtained was the following, in the login view the type of the buttons was changed since there were two submit buttons, leaving the code like this
The route remained the same and the most important change was in the controller, first a seeder was created to enter the data and send our hashed password
Complementing the seeder, the change was made in the default file that Laravel brings "DatabaseSeeder" being like this
And in our controller there was confusion because we were putting a validate when the necessary thing was to authenticate, leaving our controller like this: