laravel 中使用tinker 验证驱动加载是否成功
【摘要】
在验证laravel 中 InvalidArgumentException Driver [WeiBo] not supported.
public function weibo()
{
return Socialite::driver('weibo')->redir...
在验证laravel 中 InvalidArgumentException Driver [WeiBo] not supported.
public function weibo() { return Socialite::driver('weibo')->redirect(); // return \Socialite::with('WeiBo')->scopes(array('email'))->redirect(); }
-
public function callback()
-
{
-
/*$code=request('code');
-
dd($code);*/
-
$oauthUser = Socialite::driver('weibo')->user();
-
// dd($oauthUser);
-
$sina_id = (int)$oauthUser->getId();
-
$name = $oauthUser->getName();
-
$nickname = $oauthUser->getNickname();
-
$email = $oauthUser->getEmail();
-
$sina_avatar = $oauthUser->getAvatar();
-
-
/* //从 Token(OAuth2)中获取用户信息
-
$token = $oauthUser->token;
-
$user = Socialite::driver('WeiBo')->userFromToken($token);
-
dd($user);*/
-
-
$where['sina_id'] = $sina_id;
-
$userDetail = ThirdLogin::where($where)->first();
-
//若sina_id用户不存在,向third_login表中添加用户信息的同时,向user表中也添加条信息,
-
//将user信息与third_login,方便前台登录查询
-
if (empty($userDetail)) {
-
$user = ThirdLogin::create(compact('sina_id', 'name', 'nickname', 'email', 'sina_avatar'));
-
-
$name = $user->nickname;
-
$avatar = $user->sina_avatar;
-
$email = $user->email;
-
$third_id = $user->sina_id;
-
$password = 0;
-
User::create(compact('name', 'password', 'email', 'avatar', 'third_id'));
-
-
//使用Auth::login(实例,true)授权登录 ,这部分代码不能拿出去优化
-
$is_user = user::where('third_id', $user->sina_id)->first();
-
Auth::login($is_user, $remember = false);
-
if (\Auth::check()) {//授权成功
-
return \redirect('/posts');
-
} else {
-
return \Redirect::back()->withErrors('授权失败');
-
}
-
// User::third_login($user);
-
} else {
-
-
$is_user = user::where('third_id', $userDetail->sina_id)->first();
-
Auth::login($is_user, $remember = false);
-
if (\Auth::check()) {//授权成功
-
return \redirect('/posts');
-
} else {
-
return \Redirect::back()->withErrors('授权失败');
-
}
-
-
// User::third_login($userDetail);
-
// return Redirect::back()->withErrors('微博用户'.$userDetail->nickname.'已存在');
-
}
-
-
-
}
文章来源: blog.csdn.net,作者:lxw1844912514,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/lxw1844912514/article/details/100028478
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)