middleware('guest:user')->except('logout'); } /** * Once the user is authenticated, we need to set * the default company into a session variable * * @return void */ public function authenticated(Request $request, User $user) : void { //$this->setCurrentCompanyId($user->companies()->first()->account->default_company_id); } public function apiLogin(Request $request) { $this->validateLogin($request); if ($this->attemptLogin($request)) return $this->itemResponse($this->guard()->user()); else return response()->json(['message' => ctrans('texts.invalid_credentials')]); } /** * Redirect the user to the provider authentication page * * @return void */ public function redirectToProvider(string $provider) { return Socialite::driver($provider)->redirect(); } /** * Received the returning object from the provider * which we will use to resolve the user * * @return redirect */ public function handleProviderCallback(string $provider) { $socialite_user = Socialite::driver($provider)->user(); if($user = OAuth::handleAuth($socialite_user, $provider)) { Auth::login($user, true); return redirect($this->redirectTo); //todo return USERACCOUNT json } //throw error } }