public function handleProviderCallback() { //$user = Socialite::with('facebook')->user(); //dd($user); try { $user = Socialite::with('facebook')->user(); } catch (Exception $e) { return redirect('/login/facebook'); } dd($user); $authUser = $this->findOrCreateUser($user); Auth::login($authUser, true); return redirect('/home'); // // 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(); // }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { // http://fallout.dev/home?autologin $user = User::where('email', '*****@*****.**')->get(); if (!empty($user[0])) { \Auth::login($user[0]); } $this->middleware('guest', ['except' => 'getLogout']); }
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 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('/'); }
/** * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postRegister(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } \Auth::login($this->create($request->all())); flash()->success('Register successful'); return redirect($this->redirectPath()); }
public function postRegister(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $user = $this->create($request->all()); \Auth::login($user); return ['key' => $user->key->key, 'admin' => $user->admin == '1' ? true : false]; }
public function postRegister(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { $request->session()->flash('loginTab', 'register'); $this->throwValidationException($request, $validator); } \Auth::login($this->create($request->all())); return redirect($this->redirectPath()); }
/** * Obtain the user information from GitHub. * * @return Response */ public function handleProviderCallback() { /* Sample of what LinkedIn returns --------------------- User {#149 ▼ +token: "AQUmcn8FTAYmj_-IkAPzcqCxhZRNR-woIX9-fH4JEvCzb7xICTy2uY3JXXiq1co8MFUxxiBsk3IJIeE2kTlH5mP6fRtBnQConCaX2F2BB6fOtbswLmcSio8M1lEo67Nrt7yXbjJueAlz4wPt4T5knXZjV95uPcP0q2XEQG5Jw0zRUhNLcKY" +id: "nZmvBPf-nh" +nickname: null +name: "Ben Allfree" +email: "*****@*****.**" +avatar: "https://media.licdn.com/mpr/mprx/0_NFyu8TZPvM4g9_tqnbS18GglvUyPN_tqn5e18GxTEZe_wF5N43u8aCI7U1puckP4vXYt75Tc0GEr" +"user": array:11 [▼ "emailAddress" => "*****@*****.**" "firstName" => "Ben" "formattedName" => "Ben Allfree" "headline" => "I turn ideas into working software." "id" => "nZmvBPf-nh" "industry" => "Computer Software" "lastName" => "Allfree" "location" => array:2 [▼ "country" => array:1 [▼ "code" => "us" ] "name" => "Reno, Nevada Area" ] "pictureUrl" => "https://media.licdn.com/mpr/mprx/0_NFyu8TZPvM4g9_tqnbS18GglvUyPN_tqn5e18GxTEZe_wF5N43u8aCI7U1puckP4vXYt75Tc0GEr" "pictureUrls" => array:2 [▼ "_total" => 1 "values" => array:1 [▼ 0 => "https://media.licdn.com/mpr/mprx/0_Y7yIKlXzoK8T6SZtx7PLnrvBolli3aZtxmGQnKEMXzr86fopjxjFqnbjkJ-" ] ] "publicProfileUrl" => "https://www.linkedin.com/in/benallfree" ] +"avatar_original": "https://media.licdn.com/mpr/mprx/0_Y7yIKlXzoK8T6SZtx7PLnrvBolli3aZtxmGQnKEMXzr86fopjxjFqnbjkJ-" } */ $data = Socialite::driver('linkedin')->user(); $user = User::whereLinkedinId($data->id)->first(); if (!$user) { $user = new User(); $user->linkedin_id = $data->id; } $user->email = $data->email; $user->firstname = $data->user['firstName']; $user->lastname = $data->user['lastName']; $user->country = $data->user['location']['country']['code']; $user->location = $data->user['location']['name']; $user->tagline = $data->user['headline']; $user->avatar_url = $data->avatar_original; $user->save(); \Auth::login($user); return redirect()->route('home')->with('success', "Welcome back, {$user->firstname}"); }
/** * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postRegister(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } \Auth::login($this->create($request->all())); // save the hashtag terms stored in the global session to the database $this->saveStoredHashtags(); return redirect($this->redirectPath()); }
/** * Obtain the user information from GitHub. * * @return Response */ public function handleProviderCallback() { try { $user = Socialite::driver('facebook')->user(); } catch (Exception $e) { return \Redirect::to('auth/facebook'); } $authUser = $this->findOrCreateUser($user); \Auth::login($authUser, true); return \Redirect::to('/'); }
public function getSocialAuthCallback($provider = null) { try { $user = $this->socialite->with($provider)->user(); } catch (Exception $e) { return redirect(null, 404); } $authUser = $this->findOrCreateUser($user); \Auth::login($authUser, true); return redirect()->route('home'); //TODO : redirect to error page }
public function getSocialAuthCallback($provider = null) { if ($user = $this->socialite->with($provider)->user()) { $authUser = $this->findOrCreateUser($user, $provider); // Log in \Auth::login($authUser, true); // Return return \Redirect::intended(); } else { return 'something went wrong'; } }
/** * Overriding from E:\Wamp\wamp\www\tagoal\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers */ public function postRegister(Request $request, AppMailer $mailer) { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } // $user = $this->create($request->all()); // $mailer -> sendEmailConfirmationTo($user); // return 1; \Auth::login($this->create($request->all())); return redirect($this->redirectPath()); }
/** * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postRegister(Request $request) { try { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } \Auth::login($this->create($request->all())); return redirect($this->redirectPath()); } catch (FailedPasswordValidationException $e) { dd($e); } }
/** * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postRegister(Request $request) { $fields = $request->only(['name', 'email', 'country', 'password', 'password_confirmation']); $validator = $this->validator($fields); if ($validator->fails()) { return \Response::json(['success' => false, 'errors' => $validator->errors()]); } $user = $this->create($request->all()); \Auth::login($user); if (!$request->ajax()) { return redirect($this->redirectPath())->with(['message' => "You're finally registered, {$user->name}"]); } return \Response::json(['success' => true]); }
public function facebookCallback() { $_user = Socialite::driver('facebook')->user(); $user = User::find($_user->getId()); $email = $_user->getEmail() ? $_user->getEmail() : ''; if (!$user) { $pass = $this->randomPassword(); $user = User::create(['id' => $_user->getId(), 'name' => $_user->getName(), 'email' => $email, 'password' => \Hash::make($pass)]); $user = User::find($_user->getId()); } $login = \Auth::login($user); if (\Auth::check()) { return redirect(''); } }
/** * Redirect user after he verifies his account from email. * * @param string $confirmation_code * @return redirect() */ protected function verify($confirmation_code) { if (!$confirmation_code) { throw new InvalidConfirmationCodeException(); } $user = User::where('confirmation_code', $confirmation_code)->first(); if (!$user) { throw new InvalidConfirmationCodeException(); } $user->confirmed = true; $user->confirmation_code = null; $user->save(); \Auth::login($user, true); \Session::flash('successLoginMessage', 'You have successfully verified your account.'); return redirect('posts'); }
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'); }
public function handleProviderCallback() { $user = Socialite::driver('facebook')->user(); $userSudahAda = \App\User::Where('idsocial', $user->getId())->first(); if ($userSudahAda) { \Auth::login($userSudahAda); } else { $newUser = new \App\User(); $newUser->idsocial = $user->getId(); $newUser->name = $user->getName(); $newUser->profile_picture = $user->getAvatar(); $newUser->email = $user->getEmail(); $newUser->save(); \Auth::login($newUser); } return redirect('home'); }
public function getActivate($userId, $activationCode) { // Получаем указанного пользователя $user = User::find($userId); if (!$user) { return $this->getMessage("Неверная ссылка на активацию аккаунта."); } // Пытаемся его активировать с указанным кодом if ($user->activate($activationCode)) { // В случае успеха авторизовываем его Auth::login($user); // И выводим сообщение об успехе return $this->getMessage("Аккаунт активирован", "/"); } // В противном случае сообщаем об ошибке return $this->getMessage("Неверная ссылка на активацию аккаунта, либо учетная запись уже активирована."); }
public function getGoogleAuthCallback() { try { $guser = Socialite::driver('google')->user(); } catch (\Exception $e) { return redirect("/auth/login"); } if ($guser) { // dd($guser); $authUser = $this->findOrCreateUser($tuser, 'google'); $authUser->confirm(); \Auth::login($authUser, true); return redirect('/'); } else { return 'something went wrong'; } }
public function getConfirm(Request $request) { $inf = $request->input('inf'); $user = \App\User::where('confirmed', $inf)->first(); if ($user) { $user->confirmed = 'confirmacion ha pasado'; $user->save(); \Auth::login($user); $zeroPoints = ['stars' => 0, 'planets' => 0, 'points' => 0]; $points = new \App\Point($zeroPoints); $user->points()->save($points); $user->roles()->attach(1); return redirect('/')->with('loginfo', \App\Myclasses\Response::requestResult('confirm')); } else { return redirect('/')->with('loginfo', \App\Myclasses\Response::requestResult('unconfirm')); } }
/** * Reset the given user's password. * * @param Request $request * @return Response */ public function postDefine(Request $request) { $v = \Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required|different:old_password|min:6', 'old_password' => 'required'], ['password.different' => 'Le champ nouveau mot de passe doit être différent du mot de passe actuel']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $email = $request->input('email'); $password = $request->input('password'); $old_password = $request->input('old_password'); if (\Auth::attempt(['email' => $email, 'password' => $old_password])) { $user = \Auth::user(); $user->password = bcrypt($password); $user->save(); \Auth::login($user); return redirect('user')->with(['status' => 'success', 'message' => 'Votre mot de passe a bien été changé']); } return redirect()->back()->with(['status' => 'danger', 'message' => 'Les identifiants email / mot de passe ne correspondent pas'])->withInput($request->only('email')); }
public function getCallback() { $type = $this->request()->segment(3); $info = Socialite::driver($type)->user(); dd($info); //已经在本站注册 if ($bind = UserBind::openId($info->getId())->first()) { $user = User::find($bind->user_id); //更新accessToken和过期时间 $bind->update(array('access_token' => $info->token)); //登录成功,跳转到登录前页面 Auth::login($user); return $this->redirect()->intended('/'); } else { //还没有在本站注册,跳转到账号绑定页面 $info->from = $type; Session::put('social-info', $info); return $this->redirect('/socialite/bind'); } }
public function registerProcess(Request $request) { $validator = $this->validator($request->all()); // validation if ($validator->fails()) { $messageErrors = $validator->errors(); $errorHtml = '<ul>'; foreach ($messageErrors as $error) { $errorHtml .= '<li>' . $error . '</li>'; } $errorHtml .= '</ul>'; $dataHTML['modal_error'] = $errorHtml; $dataHTML['success'] = false; return response()->json($dataHTML); } // save now Auth::login($this->create($request->all())); $dataHTML['success'] = true; return response()->json($dataHTML); }
public function postRegistration() { $input = \Input::all(); $validator = \Validator::make($input, User::getRegistrationRules()); if ($validator->passes()) { $generated_password = str_random(8); $user = new User(); $user->firstname = \Input::has('firstname') ? $input['firstname'] : ''; $user->lastname = \Input::has('lastname') ? $input['lastname'] : ''; $user->phone = \Input::has('phone') ? $input['phone'] : ''; $user->password = \Hash::make($generated_password); if (!$user->save()) { return redirect('/registration')->withInput()->withErrors(['firstname' => 'Что-то пошло не так. Попробуйте еще раз.']); } } else { return redirect('/registration')->withInput()->withErrors($validator); } \Log::info('<!> Created : ' . $user); //send password via sms $phone_formatted = '7' . str_replace(['(', ')', ' ', '-'], '', $user->phone); $body = file_get_contents("http://sms.ru/sms/send?api_id=1408895e-223f-25e4-75b1-7c25b1caf620&from=79273818046&to=" . $phone_formatted . "&text=" . urlencode("Привет! Твой пароль для входа: " . $generated_password)); \Auth::login($user); return redirect('/'); }
public function postRegister(Request $request) { ///验证用户输入数据 $postData = $request->all(); $email = $postData['email']; $password = $postData['password']; $user = $request->user(); $data = array('currentUser' => $user); $validator = Validator::make($postData, ['email' => 'required|email|max:255|unique:users']); if ($validator->fails()) { //array_add($data,'message','email已经被注册或者密码不符合规范'); return response()->json(array('message' => 'error')); } ///创建用户 $createUser = new User(); $createUser->email = $email; $createUser->password = bcrypt($password); //$createUser->key = bcrypt($email); //$createUser->referrerkey= $referrerkey; $createUser->save(); Auth::login($createUser); $data = array('currentUser' => $createUser, 'message' => 'ok'); return view('auth.login')->with($data); }
protected function resetPassword($user, $password) { $user->password = bcrypt($password); $user->save(); \Auth::login($user); }
/** * Obtain the user information from GitHub. * * @return Response */ public function handleProviderCallback($provider) { if ($provider == 'facebook') { $user = Socialite::driver('facebook')->user(); $q = User::where('email', $user->email)->first(); if ($q) { \Auth::login($q); } else { $r = new User(); $r->name = $user->getName(); $r->email = $user->getEmail(); $r->genero = $user->user['gender']; $r->password = $user->token; $r->avatar = $user->getAvatar(); $r->role = 'editor'; $r->save(); $p = new Profile(); $p->user_id = $r->id; if ($r->genero == 'mujer') { $p->interes = 'hombre'; } else { $p->interes = 'mujer'; } $p->edad_min = 18; $p->edad_max = 25; $p->save(); \Auth::login($r); } return Redirect::route('user.compras'); } elseif ($provider == 'twitter') { $user = Socialite::driver('twitter')->user(); $q = User::where('password', $user->token)->first(); //dd($user); if ($q) { \Auth::login($q); } else { $r = new User(); $r->name = $user->getName(); $r->email = str_random(60); $r->password = $user->token; $r->avatar = $user->avatar_original; $r->role = 'editor'; $r->genero = 'hombre'; $r->save(); $p = new Profile(); $p->user_id = $r->id; if ($r->genero == 'hombre') { $p->interes = 'mujer'; } else { $p->interes = 'hombre'; } $p->edad_min = 18; $p->edad_max = 25; $p->descripcion = 'Escribe tus gustos :)'; $p->save(); \Auth::login($r); } return Redirect::route('user.compras'); } }
public function postVendorRegister(Request $request) { try { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } DB::beginTransaction(); // Create User first $user = $this->create($request->all(), config('app.role_vendor')); // Now validate / create vendor profile $data = $request->all(); $vendorValidator = $this->vendorValidator($data); if ($vendorValidator->fails()) { $this->throwValidationException($request, $vendorValidator); } // Attempt to upload the images $uploader = new UploadHandler(); if ($request->hasFile('logo_image_path') && $request->file('logo_image_path')->isValid() && $uploader->isImage($request->file('logo_image_path'))) { $newFilename = $uploader->uploadVendorAsset($request->file('logo_image_path')); $data['logo_image_path'] = $newFilename; } if ($request->hasFile('background_image_path') && $request->file('background_image_path')->isValid() && $uploader->isImage($request->file('background_image_path'))) { $newFilename = $uploader->uploadVendorAsset($request->file('background_image_path')); $data['background_image_path'] = $newFilename; } $vendor = $this->createVendor($user->id, $data); DB::commit(); \Auth::login($user); } catch (\Exception $ex) { DB::rollBack(); throw $ex; } // Send an email to us to notify of new vendor registration try { $mailData = ['to' => config('app.vendor_registration_notify_email'), 'from' => $user->email, 'subject' => 'Vendor ' . $user->email . ' has registered', 'body' => 'Vendor sign up: Email:' . $user->email . ', Company Name: ' . $vendor->company_name, 'sendRaw' => true]; $this->dispatch(new SendEmail($mailData)); } catch (\Exception $ex) { // If email fails do not stop registration from happening } return redirect($this->redirectPath()); }