zoukankan      html  css  js  c++  java
  • laravel 中使用tinker 验证驱动加载是否成功

    在验证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.'已存在');
            }
    
    
        }
    

  • 相关阅读:
    Centos 通过yum的方式升级内核
    docker入门——镜像简介
    docker入门——管理容器
    docker入门——安装及简单操作
    docker入门——简介
    Centos 6安装 Jenkins
    Centos 7 搭建OpenStack 私有云——(1)基础环境配置
    Python正则表达式
    多选控件multipicker
    绝对定位 软键盘弹出时顶起底部按钮
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15454068.html
Copyright © 2011-2022 走看看