当前位置: 首页>>代码示例>>PHP>>正文


PHP Socialite::with方法代码示例

本文整理汇总了PHP中Laravel\Socialite\Facades\Socialite::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Socialite::with方法的具体用法?PHP Socialite::with怎么用?PHP Socialite::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Laravel\Socialite\Facades\Socialite的用法示例。


在下文中一共展示了Socialite::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     if (in_array($this->provider, $this->allowedProviders)) {
         $user = User::findByUserNameOrCreate(Socialite::with($this->provider)->user());
         $this->auth->login($user);
     }
 }
开发者ID:jbmadking,项目名称:bottlestore,代码行数:12,代码来源:FindOrCreateSocialiteUser.php

示例2: handleProviderCallback

 public function handleProviderCallback()
 {
     $user = Socialite::with('battlenet')->user();
     $authUser = $this->findOrCreateUser($user);
     Auth::login($authUser, true);
     return redirect()->route('home');
 }
开发者ID:Kehet,项目名称:wow-calendar,代码行数:7,代码来源:AuthController.php

示例3: getSocialRedirect

 public function getSocialRedirect($provider)
 {
     $providerKey = \Config::get('services.' . $provider);
     if (empty($providerKey)) {
         return view('pages.status')->with('error', 'No such provider');
     }
     return Socialite::with($provider)->redirect();
 }
开发者ID:leloulight,项目名称:holidays-on-village,代码行数:8,代码来源:AuthController.php

示例4: getLogin

 /**
  * Store a newly created resource in storage.
  * @Get("/{provider}/callback", as="social.login.getLogin")
  * @param string $provider
  * @return \Illuminate\Http\Response
  */
 public function getLogin($provider)
 {
     $userData = Socialite::with($provider)->user();
     Log::debug(print_r($userData, true));
     $user = User::firstOrCreate(['username' => $userData->nickname, 'email' => $userData->email]);
     Auth::login($user);
     return response()->redirectToRoute('articles.getIndex');
 }
开发者ID:picolit,项目名称:bbs,代码行数:14,代码来源:SocialLoginController.php

示例5: getSocialAuthCallback

 public function getSocialAuthCallback($provider = null)
 {
     if ($user = Socialite::with($provider)->user()) {
         dd($user);
     } else {
         return 'something went wrong';
     }
 }
开发者ID:sangemi,项目名称:boon-v1,代码行数:8,代码来源:AuthController.php

示例6: handleProviderCallback

 /**
  * Obtain the user information from Google.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     try {
         $user = Socialite::with('google2')->user();
     } catch (ClientException $e) {
         Log::error($e->getResponse()->getBody()->getContents());
     }
     $authUser = $this->findOrCreateUser($user);
     Auth::login($authUser, true);
     return redirect('/');
 }
开发者ID:baopham,项目名称:gdrive-comments,代码行数:16,代码来源:AuthController.php

示例7: logged_in

 public function logged_in($type)
 {
     $userData = Socialite::with($type)->user();
     $email = $userData->email;
     if (empty($email)) {
         //Fallback on nickname for twitter
         $email = $userData->nickname;
     }
     //TODO: Save email/nickname in login column
     //TODO: Add displayname and ask for it after login
     //TODO: Ask for email after login
     $user = User::firstOrNew(['email' => $email, 'name' => $userData->name]);
     $user->save();
     Auth::login($user, true);
     return redirect('/');
 }
开发者ID:pelletiermaxime,项目名称:nhlpool,代码行数:16,代码来源:SocialLoginController.php

示例8: handleProviderGoogleCallback

 public function handleProviderGoogleCallback()
 {
     $userSocilite = Socialite::with('google')->user();
     $data = ['name' => $userSocilite->name, 'email' => $userSocilite->email, 'password' => $userSocilite->token];
     $user = User::where('email', '=', $userSocilite->email)->first();
     if ($user) {
         Auth::login($user);
         return redirect('home')->with(['success', trans('messages.success.login')]);
     } else {
         if ($this->create($data)) {
             $user->roles()->attach(3);
             $user = User::where('email', '=', $userSocilite->email)->first();
             Auth::login($user, true);
             return redirect('home')->with(['success', trans('messages.success.login')]);
         }
         return redirect('home')->with(['error', trans('messages.error.login')]);
     }
 }
开发者ID:uusa35,项目名称:turnkw,代码行数:18,代码来源:SocialAuthTrait.php

示例9: facebook_handleProviderCallback

 public function facebook_handleProviderCallback()
 {
     $user = \Laravel\Socialite\Facades\Socialite::with('facebook')->stateless()->user();
     echo $user->getName();
     return view('facebook');
 }
开发者ID:lilikokalova,项目名称:diplomna-rabota,代码行数:6,代码来源:AuthController.php

示例10: function

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use Illuminate\Support\Facades\Route;
use Laravel\Socialite\Facades\Socialite;
use App\Developer;
Route::get('/', function () {
    $developers = Developer::all();
    return view("index", ["developers" => $developers]);
});
Route::get("redirect/github", function () {
    return Socialite::with("github")->redirect();
});
Route::get("connect/github", function () {
    $data = Socialite::with("github")->user();
    $developer = Developer::where("github_id", $data->id)->first();
    if (!$developer) {
        Developer::create(["github_id" => $data->id, "github_nickname" => $data->nickname, "github_name" => $data->name, "github_email" => $data->email, "github_avatar" => $data->avatar]);
    }
    return redirect("/");
});
开发者ID:setkyar,项目名称:dependable,代码行数:30,代码来源:routes.php

示例11: callback

 public function callback($slug)
 {
     if (Input::has('code')) {
         $provider = Provider::where('slug', '=', $slug)->firstOrFail();
         try {
             $extern_user = Socialite::with($slug)->user();
         } catch (InvalidStateException $e) {
             return Redirect::to('/auth/login')->withErrors(['授权失效']);
         }
         //检查是否已经连接过
         $identity = Identity::where('provider_id', '=', $provider->id)->where('extern_uid', '=', $extern_user->id)->first();
         if (is_null($identity)) {
             Session::put('connect_data', ['provider_id' => $provider->id, 'extern_uid' => $extern_user->id, 'nickname' => $extern_user->nickname]);
             return Redirect::to('/auth/landing');
         }
         //已经连接过,找出user_id, 直接登录
         $user = User::find($identity->user_id);
         if (!Auth::check()) {
             Auth::login($user, true);
             //event(new UserWasLoggedinEvent($user));
         }
         return Redirect::to('/')->withSuccess(sprintf('%s %s', trans('gitamin.awesome'), trans('gitamin.login.success_oauth', ['provider' => $provider->name])));
     }
 }
开发者ID:gitaminhq,项目名称:gitamin,代码行数:24,代码来源:AuthController.php

示例12: pageFacebook

 public function pageFacebook()
 {
     $user = Socialite::with('facebook')->user();
     return response()->json($user);
 }
开发者ID:mariosas,项目名称:plusf,代码行数:5,代码来源:FacebookController.php

示例13: getSocialite

 public function getSocialite()
 {
     $type = $this->request()->segment(3);
     return Socialite::with($type)->redirect();
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:5,代码来源:AuthController.php

示例14: login

 public function login($provider)
 {
     return Socialite::with($provider)->redirect();
 }
开发者ID:avil13,项目名称:lab.friends,代码行数:4,代码来源:SocialController.php

示例15: callback

 public function callback($provider)
 {
     $provider = strtolower($provider);
     $oauthUser = Socialite::with($provider)->user();
     $uid = OAuthAccount::where('oauth_id', $oauthUser->getId())->where('oauth_type', $provider)->pluck('uid');
     if ($uid && ($user = Sentinel::findById($uid))) {
         Sentinel::login($user);
         return redirect($this->redirectPath());
     }
     // 如果当前第三方账号没有绑定我站账号,那么跳转到绑定账号的页面
     Session::put(self::OAUTH_USER, array('provider' => $provider, 'user' => $oauthUser));
     return redirect()->action('Auth\\AuthController@getBind');
 }
开发者ID:Mr-jing,项目名称:imojie,代码行数:13,代码来源:AuthController.php


注:本文中的Laravel\Socialite\Facades\Socialite::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。