本文整理汇总了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);
}
}
示例2: handleProviderCallback
public function handleProviderCallback()
{
$user = Socialite::with('battlenet')->user();
$authUser = $this->findOrCreateUser($user);
Auth::login($authUser, true);
return redirect()->route('home');
}
示例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();
}
示例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');
}
示例5: getSocialAuthCallback
public function getSocialAuthCallback($provider = null)
{
if ($user = Socialite::with($provider)->user()) {
dd($user);
} else {
return 'something went wrong';
}
}
示例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('/');
}
示例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('/');
}
示例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')]);
}
}
示例9: facebook_handleProviderCallback
public function facebook_handleProviderCallback()
{
$user = \Laravel\Socialite\Facades\Socialite::with('facebook')->stateless()->user();
echo $user->getName();
return view('facebook');
}
示例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("/");
});
示例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])));
}
}
示例12: pageFacebook
public function pageFacebook()
{
$user = Socialite::with('facebook')->user();
return response()->json($user);
}
示例13: getSocialite
public function getSocialite()
{
$type = $this->request()->segment(3);
return Socialite::with($type)->redirect();
}
示例14: login
public function login($provider)
{
return Socialite::with($provider)->redirect();
}
示例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');
}