好吧,为了保持简单,我有一个users
表和User
模型。该表包含一个唯一标识符com_id
(加上其他用户信息),我想用它登录,但没有密码。Laravel:使用Auth驱动程序登录,但没有密码
我想登录的用户,并能够通过验证驱动程序来访问他们的数据:Auth::user()->email
等,但我有一些问题记录他们
if (Auth::attempt(['com_id' => $com_id]))
{
dd("successful login");
}
有了这个,。我得到关于UserInterface
一个错误,所以在我的模型我补充一下:
use Illuminate\Auth\UserInterface;
class User extends Eloquent implements UserInterface {
protected $table = 'users';
protected $guarded = array('id');
public function getAuthIdentifier()
{
return $this->steam_community_id;
}
public function getAuthPassword()
{
return $this->password;
}
}
可是我该怎么办有关密码?我不能删除该功能,因为它是必需的,我不确定getAuthIdentifier
应该指什么?
任何帮助将是很好的。
我可以通过Sessions处理这个问题,但肯定这是“正常”的方式。
看看[this](http://laravel.com/docs/security#manually)。你也可以使用Auth :: loginUsingId()。 – Uze
想想我曾尝试过,但它似乎没有太多,但我会再试一次,但这是唯一的方法吗? – Alias