I have one route, this route call my controller. Inside this controller I have :
$user = Auth::loginUsingId(1); // This data get from a form
$mail = $user->email;
$pass = $user->password;
$credentials = [
'email' => $mail,
'password' => $pass,
];
if (Auth::once($credentials)) {
return Auth::user()->id;
}
return \App\Login::where('email', '=', $mail)->where('password', '=',$pass)->first(); // I can see my user, with his email and password. It is a exmplante, later when this is working I will put false
My model is Login.php instead of User.php
class Login extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract {
use Authenticatable, Authorizable, CanResetPassword;
protected $table = 'logins';
protected $fillable = ['email','password'];
protected $hidden = ['created_at','updated_at_at'];
public function setPasswordAttribute($password)
{
$this->attributes['password'] = bcrypt($password);
}
And I change the file config/auth.php
'driver' => 'eloquent',
'model' => \App\Login::class,
'table' => 'logins',
'password' => [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],
I try use the Auth::attempt() but I have the same problem, I do not understand because I can connect my database, I config the new model in config/auth ...
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire