1
Good afternoon, I am using Laravel 5 to redo a system and on the login screen when authentication is not made the user is redirected to the form again but I can not return any error.
Model User
protected $connection = 'pgsql2';
protected $primaryKey = 'cod_funcionario';
public $timestamps = false;
protected $table = 'funcionarios';
protected $fillable = ['login', 'senha'];
protected $hidden = ['senha', 'remember_token'];
public function getAuthPassword()
{
return $this->senha;
}
public function setSenhaAttribute($value)
{
$this->attributes['senha'] = bcrypt($value);
}
Authcontroller.php
protected $redirectPath = '/admin';
protected $loginPath = '/admin/auth/login';
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
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' => $data['password'],
//'password' => bcrypt($data['password']),
]);
}
public function postAdminLogin()
{
if (Auth::attempt(['login' => Request::input('login'), 'password' => Request::input('senha')]))
{
return redirect()->intended('admin');
}
else{
return Redirect::to('admin/auth/login');
}
and in the view I’m trying to display the errors as follows:
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{!! $error !!}</li>
@endforeach
</ul>
</div>
@endif
Friend, post the code you already have, will help and MUCH will help you.
– mauricio caserta
I posted, if you need any more.
– Matheus Ilário
Look at the answer I posted.
– Diego Souza