我想让用户通过提供他/她的
登录以及密码,类似于它在Facebook和LinkedIn中的工作方式。
使用Laravel 5.2默认身份验证实现此目的的最佳/优雅方式是什么?
答案 0 :(得分:1)
根据我的知识,没有第三方解决方案可用。
这是我的工作示例,我是如何做到的...这个postLogin
一些示例代码。
$credentials = $this->getCredentials($request);
$credentials_username = ['username'=>$credentials['username'], 'password'=>$credentials['password']];
$credentials_email = ['email'=>$credentials['username'], 'password'=>$credentials['password']];
$credentials_phone = ['phone'=>$credentials['username'], 'password'=>$credentials['password']];
//adedd custom, we also want to check by username too
if (Auth::attempt($credentials_email, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
//also check for the username if exists then login to the system
}elseif (Auth::attempt($credentials_username, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
//also check for phone no
}elseif (Auth::attempt($credentials_phone, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
}