public function handleCallback($driver, Request $req) { $socialuser = \Socialize::with($driver)->user(); $user = User::where('email', $socialuser->email)->first(); if (count($user) < 1) { $user = new User(); $user->id = (string) Uuid::generate(); $user->email = $socialuser->email; $user->name = $socialuser->name; $user->avatar = $socialuser->avatar; $user->save(); } $user = \Auth::loginUsingId($user->id); $authcookie = \Cookie::queue('authenticated', true, 20, null, "www.thinkmerit.in", false, false); $username = \Cookie::queue('name', $user->name, 20, null, "www.thinkmerit.in", false, false); $avatar = \Cookie::queue('avatar', $user->avatar, 20, null, "www.thinkmerit.in", false, false); $email = \Cookie::queue('email', $user->email, 20, null, "www.thinkmerit.in", false, false); if (app()->environment() == "production") { return \Redirect::to("http://www.thinkmerit.in"); } else { return \Redirect::to("http://www.dev.thinkmerit.in"); } /* ->withCookie($authcookie) ->withCookie($username) ->withCookie($avatar) ->withCookie($email);*/ // ; }
public function socialite_login($outh_type) { // $user_data = [ // "site_type"=>$outh_type, // "site_id"=>112617558420458089489, // "email"=>"*****@*****.**", // "name"=>"ahmed badawy", // "avatar"=>get_it('site/logo.jpg') // ]; // $data = [ // 'route_info'=>\sr::common("projects_index"), // 'theme'=>$this->themes[0], // 'user_data'=>$user_data // ]; // return $this->get_view("spidro.user_area.show_data",$data,'spidro'); die; $user = \Socialize::with($outh_type)->user(); $user_data = ["site_type" => $outh_type, "site_id" => $user->id, "email" => $user->email, "name" => $user->name, "avatar" => $user->avatar]; if (isset($user->user['url'])) { $data["url"] = $user->user['url']; } if (isset($user->user['gender'])) { $data["gender"] = $user->user['gender']; } if (isset($user->user['relationshipStatus'])) { $data["relationshipStatus"] = $user->user['relationshipStatus']; } $db_user = \spidro_users_model::create($user_data); \Session::put("user_data", $db_user); // dd($user_data); $data = ['route_info' => \sr::common("projects_index"), 'theme' => $this->themes[0], 'user_data' => $user_data]; return $this->get_view("spidro.user_area.show_data", $data, 'spidro'); }
public function github() { $user = Socialize::with('github')->user(); // Do your stuff with user data. print_r($user); die; }
public function facebook() { $user = \Socialize::with('facebook')->stateless()->user(); if (count(User::where('email', '=', $user->email)->get()) == 0) { return view('register', ['user' => $user->user]); } }
public function getFacebookCallback() { $user = \Socialize::with('facebook')->user(); // All Providers $user->provider = "facebook"; $user = User::findByUserNameOrCreate($user); \Auth::login($user); return redirect()->intended('home'); }
public function socialize($provider) { // Get the provider instance $provider = Socialize::with($provider); if (Input::has('code')) { $user = $provider->user(); dd($user); return View::make('facebook', ['user' => $user]); } else { return $provider->redirect(); } }
public function getConnect($provider = 'facebook') { if (\Input::all()) { try { $this->addProfile($provider, \Auth::user(), \Socialize::with($provider)->user()); $this->flashMessage('Sucessfully connected to ' . ucfirst($provider) . '.'); } catch (\Exception $e) { $this->flashMessage('Error connecting to provider: ' . $e->getMessage(), 'alert-danger'); } return redirect('/admin/profile'); } else { $scopes = $provider == 'facebook' ? ['manage_pages', 'publish_pages'] : []; return \Socialize::with($provider)->scopes($scopes)->redirect(); } }
public function callback() { $linkedin_user = \Socialize::with('linkedin')->user(); error_log(json_encode($linkedin_user->id)); $user = \App\User::where('provider_id', $linkedin_user->id)->first(); error_log(json_encode($user)); if (!$user) { $user = \App\User::create(['email' => $linkedin_user->email, 'photo' => $linkedin_user->avatar, 'name' => $linkedin_user->name, 'confirmed' => 1, 'provider' => 'linkedin', 'provider_id' => $linkedin_user->id]); error_log(json_encode($user)); } else { $user->update(['email' => $linkedin_user->email, 'photo' => $linkedin_user->avatar, 'name' => $linkedin_user->name, 'confirmed' => 1, 'provider' => 'linkedin', 'provider_id' => $linkedin_user->id]); error_log(json_encode($user)); } \Auth::login($user, true); return redirect('/dashboard'); }
/** * Display the specified resource. * * @param int $articleId * @return Response */ public function show($articleId = 1) { // $user = Socialize::with('facebook')->user(); // Провайдеры, использующие OAuth v.2.0 $token = $user->token; // Провайдеры, использующие OAuth v.1.0 $token = $user->token; $tokenSecret = $user->tokenSecret; // Все провайдеры $user->getNickname(); $user->getName(); $user->getEmail(); $user->getAvatar(); print_r($user); return view('page'); }
/** * @param Request $request * * @throws HttpException * * @return \Illuminate\Http\RedirectResponse */ public function handle(Request $request) { $provider = $request->get('provider'); if ($provider === null) { throw new HttpException(500, 'provider necessary'); } /** @var OneUser|TwoUser $data */ $data = \Socialize::with($provider)->user(); // do we got the user already? $user = User::where('email', $data->getEmail())->first(); if ($user === null) { // we have to register him as a new user $user = User::create(['name' => $data->getName(), 'email' => $data->getEmail(), 'password' => '']); } // login as db user Auth::login($user); return redirect($this->redirectPath); }
public function remote_auth_back($outh_type) { // if($outh_type=='facebook'){ // }elseif($outh_type=="github"){ // }elseif($outh_type=="google"){ // }elseif($outh_type=="twitter"){ // } $user = \Socialize::with($outh_type)->user(); dd($user); redirect("spidro/socialite/login")->withInput(); //->with(['user',$user]); // OAuth Two Providers // $token = $user->token; // OAuth One Providers // $token = $user->token; // $tokenSecret = $user->tokenSecret; // All Providers // $user->getId(); // $user->getNickname(); // $user->getName(); // $user->getEmail(); // $user->getAvatar(); }
public function googleRedirect() { return \Socialize::with('google')->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('/', function () { return view('page'); }); Route::resource('page', 'ArticleResourceController'); Route::get('redirectToProvider', function () { return Socialize::with('facebook')->redirect(); }); Route::get('handleProviderCallback', function () { $user = Socialize::with('facebook')->user(); // $user->token; });
public function twitter() { $user = \Socialize::with('facebook')->user(); dd($user); }
public function twitter() { $twitter_user = \Socialize::driver('twitter')->user(); //echo $twitter_user->nickname."CCC"; //echo "<pre>"; //print_r($twitter_user); //echo "</pre>"; //exit; $name = $twitter_user->name; $email = $twitter_user->email; $u_name = preg_replace('/@.*$/', '', $email); $input['email'] = $email; $rules = array('email' => 'unique:users,email'); $validator = \Validator::make($input, $rules); $credentials = array('email' => $email, 'password' => $u_name); if ($validator->fails()) { if (\Auth::attempt($credentials)) { return redirect('/home')->with('message', 'Successfully logged in with Twitter'); } } else { // Register the new user or whatever. $user = new User(); $user->name = $name; $user->type = 'general'; $user->register_type = 'twitter'; $user->username = $u_name; $user->email = $email; $user->password = bcrypt($u_name); $user->save(); $user_obj = User::where('email', $email)->first(); $profile = new Profile(); $profile->user_id = $user_obj->id; $profile->save(); if (\Auth::attempt($credentials)) { return redirect('/home')->with('message', 'Successfully logged in with Twitter'); } } }
public function github(){ $user = \Socialize::with('github')->user(); return $user->getName(). ' '.$user->getEmail().'<br />'.$user->getNickname().'<br /><img src="'.$user->getAvatar().'" alt="foto">'; //return $user->token; }
<?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('/', 'DashboardController@index'); Route::get('login', 'SessionsController@create'); Route::post('login', 'SessionsController@store'); Route::get('logout', 'SessionsController@destroy'); Route::resource('sessions', 'SessionsController', ['only' => ['index', 'create', 'destroy']]); Route::get('login/facebook', function () { return Socialize::with('facebook')->redirect(); }); Route::get('login/facebook/callback', 'SessionsController@facebook');
public function login_facebook_callback() { $user = \Socialize::with('facebook')->user(); return $this->user_service->authenticate_facebook_user($user); }
public function getLogin($provider) { return \Socialize::with($provider)->redirect(); }
public function handleProviderCallback() { $user = Socialize::with('github')->user(); // $user->token; }
Route::group(['prefix' => 'admin', 'middleware' => 'auth', 'namespace' => 'Admin'], function () { Route::resource('users', 'UsersController'); }); Route::controllers(['users' => 'UsersController']); Route::get('github', 'AccountController@github_redirect'); Route::get('account/github', 'AccountController@github'); /*Route::get('auth', function(){ return OAuth::authorize('facebook'); }); Route::get('login2', 'WelcomeController@index');*/ Route::get('/iniciar-sesion', function () { return Socialize::driver('facebook')->redirect(); }); Route::get('/callback', function () { $user = Socialize::driver('facebook')->user(); dd($user); }); Route::get('/storage/create', 'StorageController@index'); Route::post('/storage/create', 'Auth\\AuthController@save'); //Route::post('/register', 'Auth\AuthController@save'); /*Route::post('/storage/{archivo}', function($archivo){ $storage_path = storage_path(); $url = $storage_path.'/archivos/'.$nombre; if (Storage::exists($archivo)){ return response()->download($url); } abort(404); });*/ Route::get('auth/profile', 'UserController@profile');