我正在使用Laravel 5.0。我只想使用用户名(无密码)进行登录,因为我使用Single Sign On访问我的Laravel项目,所以如果用户成功登录单点登录,它将检查我的数据库是否登录用户的用户名已注册与否。
我一直在寻找这一整天,但我仍然找到了线索。
我已经得到了一个错误:如何在Laravel 5.0中使用Auth :: attempt无密码登录?
Argument 1 passed to Illuminate\Auth\Guard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given
如果我使用下面的代码在我的LoginController:
$user = User::where('USER_NAME', '=', $_GET['UserName'])->first();
if(Auth::login($user)->USER_ID == $_GET['UserName']){
return redirect('Home');
}
如果我在我的LoginController使用下面的代码:
if(Auth::attempt(['USER_ID' => $_GET['UserName']])){
return redirect('Home');
}
我得到一个错误:
Undefined index: password
我已经尝试过,并且在Application.php行901中有一个错误'NotFoundHttpException:' – hendraspt
不确定。我试过我的代码,它工作正常。 – Sovon