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.']); }
/** * Handle the event. * * @param GoogleLoggedIn $event * @return void */ public function handle(GoogleLoggedIn $event) { $user = $event->user; try { $mUser = User::where('google_id', $user->id)->firstOrFail(); $mUser->avatar = $user->getAvatar(); $mUser->google_url = isset($user->user['link']) ? $user->user['link'] : 'http://'; $mUser->name = $user->getName(); } catch (ModelNotFoundException $e) { $mUser = new User(); $mUser->name = $user->getName(); $mUser->email = $user->getEmail(); $mUser->google_id = $user->user['id']; $mUser->avatar = $user->getAvatar(); $mUser->google_url = isset($user->user['link']) ? $user->user['link'] : 'http://'; } $mUser->save(); }
/** * Register any other events for your application. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function boot(DispatcherContract $events) { parent::boot($events); User::creating(function ($user) { if (User::count() == 0) { $user->admin = true; } }); }
public function postUpdate() { $all = $this->request->all(); if (isset($all['google_id'])) { try { $user = User::where('google_id', $all['google_id'])->firstOrFail(); if ($user->account_id != 0 && $user->account->h5 instanceof Data) { $old_h5 = clone $user->account->h5; $this->dispatch(new UpdateHalo5Account($user->account)); $new_h5 = Data::where('account_id', $user->account_id)->first(); $msg = MessageGenerator::buildH5UpdateMessage($user->account, $old_h5, $new_h5); return Response::json(['error' => false, 'msg' => $msg], 200); } else { return Response::json(['error' => false, 'msg' => 'bitch pls. You need to confirm your gamertag on PandaLove so I know who you are.'], 200); } } catch (ModelNotFoundException $e) { return $this->_error('User account could not be found.'); } } }
public function postSetup() { $all = $this->request->all(); if (isset($all['chat_id']) && isset($all['google_id'])) { try { $user = User::where('google_id', $all['google_id'])->firstOrFail(); $user->chat_id = $all['chat_id']; $user->save(); return Response::json(['error' => false, 'msg' => 'Updated ChatId to <strong>' . $all['chat_id'] . '</strong>. I will PM you here for alerts.'], 200); } catch (ModelNotFoundException $e) { return $this->_error('I do not know who you are. Therefore I cannot set your chat ID.'); } } else { return $this->_error('Chat/Google ID not found.'); } }
public function postAddGame() { $all = $this->request->all(); if (isset($all['google_id'])) { try { $user = User::where('google_id', $all['google_id'])->where('admin', true)->firstOrFail(); $client = new Client(); try { $game = $client->fetchGameByInstanceId($all['instanceId']); } catch (GameNotFoundException $e) { return $this->_error('Game could not be found'); } $client->updateTypeOfGame($all['instanceId'], Types::getProperFormat($all['type']), $all['passageId']); return Response::json(['error' => false, 'msg' => 'Game Added! '], 200); } catch (ModelNotFoundException $e) { return $this->_error('User account could not be found.'); } } }