Auth :: once($ credentials)总是假的

时间:2016-08-01 10:14:21

标签: php laravel-5 oauth-2.0 laravel-5.1

我有一条路线,这条路线叫我的控制器。在这个控制器里面我有:

  $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

我的模型是Login.php而不是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);
    }
}

我更改了文件config / auth.php

    'driver' => 'eloquent',
    'model' => \App\Login::class,
    'table' => 'logins',

    'password' => [
        'email'  => 'emails.password',
        'table'  => 'password_resets',
        'expire' => 60,
    ],

我尝试使用Auth :: attempt()但我有同样的问题,我不明白,因为我可以连接我的数据库,我在config / auth中配置新模型......

0 个答案:

没有答案