Well I'm developing a login
itself and I have other campos
and another tabela
, everything goes perfectly but always returns false
result.
I changed the file Authenticatable.php
within \Illuminate\AuthZAuthenticatable
to:
public function getAuthPassword()
{
return $this->password; //anteriormente era assim
return $this->Senha;
}
In my file auth.php
within config
it looks like this:
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'pessoas',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'pessoas',
],
'api' => [
'driver' => 'token',
'provider' => 'pessoas',
],
],
'providers' => [
'pessoas' => [
'driver' => 'eloquent',
'model' => App\Pessoa::class,
],
'pessoas' => [
'driver' => 'database',
'table' => 'pessoas',
],
],
'passwords' => [
'pessoas' => [
'provider' => 'pessoas',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
];
My model Pessoa
looks like this:
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Pessoa extends Authenticatable
{
use SoftDeletes;
protected $fillable = [
'NmPessoa',
'CPF',
'Email',
'Senha',
'Telefone',
'DtNasc',
'Sexo',
'FglNewsLater',
'FglStPessoa',
'ObsPessoa',
'FglADM',
'FglCliente',
'FglFuncionario',
'Cidade',
'Estado',
'Bairro',
'Rua',
'Num',
'Complemento',
'CEP'
];
protected $hidden = [
'Senha', 'remember_token',
];
protected $primaryKey = 'CdPessoa';
protected $dates = ['deleted_at'];
public function setPasswordAttribute($Senha)
{
$this->attributes['Senha'] = bcrypt($Senha);
}
}
In my controller AuthController
I did like this:
use Auth;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class AuthController extends Controller
{
public function authenticate(Request $request)
{
$email = $request->input('email');
$password = $request->input('senha');
dd(Auth::attempt(['Email' => $email, 'Senha' => $password]));
if (Auth::attempt(['Email' => $email, 'Senha' => $password])) {
// Authentication passed...
return redirect()->intended('/');
}
}
}
And in my HTML:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
{{ csrf_field() }}
<div class="form-group">
<input type="email" name="email" lass="form-control" id="email-modal" placeholder="E-mail">
</div>
<div class="form-group">
<input type="password" name="senha" class="form-control" id="password-modal" placeholder="Senha">
</div>
<p class="text-center">
<button type="submit" class="btn btn-primary"><i class="fa fa-sign-in"></i> Entrar</button>
</p>
</form>
With all this, what could be the cause of the problem.
Thinking here I think it could be the part of
senha
encrypted, I saved in the database it bcrypt (Password), already tried to change this part the attempt () but it did not work and continued giving false. Remember that I have the user in the database.