當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。