private function handleProviderCallback() { $user = \Socialite::with('google')->user(); \Event::fire(new GoogleLoggedIn($user)); \Auth::login(User::where('google_id', $user->id)->first(), true); return \Redirect::to('/')->with('flash_message', ['type' => 'green', 'close' => true, 'header' => 'Your sign in was successful.', 'body' => 'You have correctly authenticated with PandaLove.']); }
public function callback($provider) { $oauthUser = \Socialite::with($provider)->user(); if (is_null($user = User::where('name', '=', $oauthUser->nickname)->first())) { $user = User::create(['name' => $oauthUser->nickname, 'email' => $oauthUser->email, 'avatar' => $oauthUser->avatar]); } Auth::login($user, true); return redirect('articles'); }
public function providerLogin($provider) { // ユーザー情報取得 $userData = \Socialite::with($provider)->user(); // ユーザー作成 $user = App\Models\User::firstOrCreate(['name' => $userData->nickname, 'email' => $userData->email, 'avatar' => $userData->avatar]); \Auth::login($user); return redirect('/'); }
public function getFacebookCallback(Request $req) { $user = \Socialite::with('facebook')->user(); $data = array('name' => $user->name, 'email' => $user->email, 'password' => $req['code']); $request = new Request(); $request = User::firstOrNew($data); $request->save(); Auth::login($request); return redirect(''); }
public function callback() { $qq = \Socialite::with('qq')->user(); if ($qq != null) { $user = $this->createUser($qq); Auth::login($user, true); return redirect('/'); } else { return view('qq.callback'); } }
public function oauth() { $code = Request::get('code', null); $type = Request::get('type', 'weibo'); if (!$code) { return \Socialite::with($type)->redirect(); } $oauth = \Socialite::with($type)->user(); dd($oauth); // return \Socialite::with('weibo')->scopes(array('email'))->redirect(); }
public function getSocialAuthCallback() { try { $providerData = \Socialite::with('facebook')->user(); } catch (Exception $e) { return redirect('/login/facebook'); } $user = User::where('provider_user_id', $providerData->id)->where('provider', 'facebook')->orWhere('email', $providerData->email)->first(); if (!$user) { $user = User::create(['email' => $providerData->email, 'name' => $providerData->name, 'provider' => "facebook", 'provider_user_id' => $providerData->id]); } Auth::login($user, true); return redirect('/dashboard'); }
public function handleProviderCallback() { $user = \Socialite::with('github')->user(); // OAuth One Providers $token = $user->token; $tokenSecret = $user->tokenSecret; echo $token; /*if(Auth::attempt($credentials)){ return Redirect::to('admin'); } else { return Redirect::to('login'); }*/ }
public function pageFacebook() { $socialize_user = \Socialite::with($provider)->user(); $facebook_user_id = $socialize_user->getId(); // unique facebook user id $user = Contributors::where('facebook_user_id', $facebook_user_id)->first(); // register (if no user) if (!$user) { $user = new Contributors(); $user->facebook_id = $facebook_user_id; $user->save(); } // login Auth::loginUsingId($user->id); return redirect('/'); }
public function getLoginFacebook() { $provider = \Socialite::with('facebook'); if (\Input::has('code')) { $user = $provider->user(); $check_email = $this->mst_user->where('email', '=', $user->email)->first(); if (count($check_email) > 0) { //jika email ada di db, forced to login \Auth::loginUsingId($check_email->id); \Log::info('login using id'); return redirect()->intended($this->redirectPath()); } else { \Log::info('gagal login, user tdk ditemukan'); return redirect()->back()->withErrors(['email' => 'User tidak ditemukan.']); } } else { \Log::info('gagal login'); return $provider->redirect(); } }
/** * Attempt to log in an user using a social authentication provider. * * @param Illuminate\Http\Request $request * @param string * @return Response */ public function loginWithProvider(Request $request, $providerSlug) { // Use provider name as the throttling cache key $request['provider'] = $providerSlug; // Check if there are too many login attempts for current provider and IP if ($this->hasTooManyLoginAttempts($request)) { // Flash error message $seconds = (int) \Cache::get($this->getLoginLockExpirationKey($request)) - time(); $message = sprintf(_('Please try again in %d seconds.'), $seconds); return $this->goBack(_('Too many login attempts') . '. ' . $message); } $this->incrementLoginAttempts($request); // If the remote provider sends an error cancel the process foreach (['error', 'error_message', 'error_code'] as $error) { if ($request->has($error)) { return $this->goBack(_('Something went wrong') . '. ' . $request->get($error)); } } // Get provider $provider = Provider::whereSlug($providerSlug)->firstOrFail(); // Make sure it's usable if (!$provider->isUsable()) { return $this->goBack(_('Unavailable provider')); } // Set provider callback url config(["services.{$provider->slug}.redirect" => \URL::current()]); // Create an Oauth service for this provider $oauthService = \Socialite::with($provider->slug); // Check if current request is a callback from the provider if ($request->has('oauth_token') or $request->has('code')) { $this->clearLoginAttempts($request); return $this->loginSocialUser($provider, $oauthService->user()); } // If we have configured custom scopes use them if ($scopes = config("services.{$provider->slug}.scopes")) { $oauthService->scopes($scopes); } // Request user to authorize our App return $oauthService->redirect(); }
public function redirectToProvider() { return Socialite::with('github')->redirect(); }
public function redirectToProvider($provider) { return Socialite::with($provider)->redirect(); }
/* |-------------------------------------------------------------------------- | 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. | */ Route::group(['prefix' => 'auth'], function () { Route::pattern('provider', 'github|twitter|facebook'); Route::get('{provider}/authorize', function ($provider) { // ソーシャルログイン処理 return \Socialite::with($provider)->redirect(); }); Route::get('{provider}/login', 'Auth\\AuthController@providerLogin'); Route::controllers(['/' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']); }); Route::get('/', function () { if (!\Auth::check()) { // ログイン済でなければリダイレクト return 'こんにちは ゲストさん. ' . link_to('github/authorize', 'Github でログイン.') . link_to('twitter/authorize', 'Twitter でログイン.') . link_to('facebook/authorize', 'Facebook でログイン.'); } return 'ようこそ ' . \Auth::user()->name . 'さん!'; }); Route::group(['middleware' => 'auth'], function () { Route::group(['prefix' => 'messages'], function () { Route::get('/', ['as' => 'messages', 'uses' => 'MessagesController@index']); Route::get('create', ['as' => 'messages.create', 'uses' => 'MessagesController@create']);
/** * this function will handle social login with facebook using socialite package. * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function facebook_callback() { $fb_user_object = \Socialite::with('facebook')->user(); $user = $this->user_repo->findByField('fb_id', $fb_user_object->user['id'])->first(); if ($user) { auth()->login($user); flash('welcome back', 'success'); return redirect('/profile/'); } else { $new_user = $this->user_repo->insert_fb($fb_user_object); if ($new_user) { flash('Welcome ' . $new_user->first_name . ' Account registered', 'success'); auth()->login($new_user); return redirect('/profile/'); } else { flash('some error occurred', 'danger'); return redirect('/login'); } } }
public function redirectToProvider() { echo 'I am here'; // echo Socialize; return \Socialite::with('facebook')->redirect(); }
public function signInFacebook() { return \Socialite::with('facebook')->redirect(); }
/** * Get google user details * @return mixed */ private function getGoogleUser() { return \Socialite::with('google')->user(); }
/** * Редиректим на нужный провайдер * @param $provider * @return mixed */ public function oauthLogin($provider) { return \Socialite::with($provider)->redirect(); }
<?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. | */ Route::get('/login', function () { return Socialite::with('github')->redirect(); }); Route::get('/session', function (Illuminate\Http\Request $req) { // Hack to set client_id and other params required to // issue an access token // Ideally I'd like to do something like issueForUserId... But alas!!! $req->request->set('client_id', 'id'); $req->request->set('client_secret', 'secret'); $req->request->set('grant_type', 'user'); $github = Socialite::driver('github'); $github->stateless(); $githubUser = $github->user(); $user = App\User::firstOrNew(['email' => $githubUser->email]); if (!$user->exists) { $user->name = $githubUser->name; $user->password = str_random(16); $user->save(); }
/* |-------------------------------------------------------------------------- | 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. | */ Route::get('/', 'PostController@index'); Route::get('twitterlogin', function () { return \Socialite::with('twitter')->redirect(); }); Route::get('fblogin', function () { return \Socialite::with('facebook')->redirect(); }); Route::get('twitter_callback', 'UserController@getTwitterCallback'); Route::get('facebook_callback', 'UserController@getFacebookCallback'); Route::get('api/v1/users', 'UserController@getUsers'); Route::get('api/v1/posts', 'PostController@getPosts'); Route::get('api/v1/comments', 'CommentController@getComments'); Route::controllers(['auth' => 'Auth\\AuthController']); Route::group(['middleware' => ['auth']], function () { // show new post form // Route::get('new-post','PostController@create'); // save new post Route::post('new-post', 'PostController@store'); // edit post form // Route::get('edit/{slug}','PostController@edit'); // update post
public function login() { return \Socialite::with('vkontakte')->redirect(); }
Route::post('search', 'BeerController@search'); Route::get('auth/login', 'Auth\\AuthController@login'); /*AJAX*/ Route::post('ajax/drinking_this', 'ProfileController@drinking_this'); Route::get('ajax/searchBeer', 'BeerController@ajax_search'); Route::post('ajax/commendBeer', 'BeerController@commendBeer'); Route::post('ajax/submitReview', 'BeerController@submitReview'); Route::get('ajax/ajaxCheckin', 'BeerController@ajaxCheckin'); Route::POST('ajax/userRating', 'ProfileController@userRating'); //---------------------------------------------------------------- Route::get('login/fb', function () { return \Socialite::with('facebook')->scopes(['email', 'user_friends', 'user_location', 'user_birthday'])->redirect(); }); //http://beerhit.com/login/fb/callback Route::get('login/fb/callback', function () { $socialize_user = \Socialite::with('facebook')->user(); $facebook_user_id = $socialize_user->getId(); // unique facebook user id $user = User::where('email', $socialize_user->email)->first(); $location = Location::get(); $city = $location->cityName; $country = $location->countryName; // dd($socialize_user); if (!$user) { $user = new User(); $user->fb_id = $facebook_user_id; $user->firstname = $socialize_user->user['first_name']; $user->lastname = $socialize_user->user['last_name']; $user->username = $socialize_user->name; $user->email = $socialize_user->email; $user->avatar = $socialize_user->avatar;