Error logging in to Laravel

0

Personally I'm having a login error in Laravel:

AuthenticationController.php

public function logar(Request $request){
    $dados = $request->all();
    $cpf = $dados['cpf'];
    $senha = $dados['senha'];

    $usuario = Usuario::where('cpf', $cpf)->first();

    if (Auth::check() || ($usuario && Hash::check($senha, $usuario->senha))){
        Auth::login($usuario);
        return view('municipios.index');
    }else{
        return view('autenticacao.login');
    }
}

web.php

Route::post('/logar', 'AutenticacaoController@login')->name('autenticacao.logar');

Login Form

<form action="{{route('autenticacao.logar')}}" method="post">
{{csrf_field()}}
    <input type="text" name="cpf" class="form-control" placeholder="CPF" />
    <br/>
    <input type="password" name="senha" class="form-control" placeholder="senha" />
    <br/>
    <button type="submit" class="btn btn-primary btn-block btn-flat">Entrar</button>
</form>

Auth.php

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'usuarios',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
    ],
],
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
    'usuarios' => [
        'driver' => 'eloquent',
        'model' => App\Usuario::class,
    ],

User.php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Usuario extends Authenticatable
{
use Notifiable;

protected $fillable = [
    "cpf", "nome", "senha", "endereco", "telefone", "municipio_id"
];
protected $table = "usuarios";

When executing the form that is in the /login route, it is directed to /logar but does not login, does not display error and the screen is the same as the previous one.

    
asked by anonymous 07.09.2018 / 20:38

1 answer

1

You are not calling the correct action , replace:

Route::post('/logar', 'AutenticacaoController@login')->name('autenticacao.logar');

By:

Route::post('/logar', 'AutenticacaoController@logar')->name('autenticacao.logar');
    
07.09.2018 / 21:10