• 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 
    edirect('/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 
    edirect('/posts');
                } else {
                    return Redirect::back()->withErrors('授权失败');
                }
    
    //            User::third_login($userDetail);
    //          return Redirect::back()->withErrors('微博用户'.$userDetail->nickname.'已存在');
            }
    
    
        }
    

  • 相关阅读:
    从泛型类中继承
    DataGridView中的单元格提示错误信息
    C#中的转换
    C#的运算符重载
    解决android模块化升级方法
    个人总结如何在项目管理的实际软件开发工作的几个关键点和控制
    bash no such file or directory in ubuntu 1404
    java 遍历树节点 同时保留所有的从根到叶节点的路径
    ZendFramework2学习笔记 json和ajax
    POJ 2531-Network Saboteur(DFS)
  • 原文地址:https://www.cnblogs.com/lxwphp/p/9487139.html
Copyright © 2020-2023  润新知