config('app.url').'/google/callback']); config(['services.google.client_id' => $setting->google_client_id]); config(['services.google.client_secret' => $setting->google_client_secret]); } public function redirectToGoogle() { return Socialite::driver('google')->redirect(); } public function handleGoogleCallback() { try { $socialUser = Socialite::driver('google')->user(); \Log::debug('Google user found in Google Workspace'); } catch (InvalidStateException $exception) { \Log::debug('Google user NOT found in Google Workspace'); return redirect()->route('login') ->withErrors( [ 'username' => [ trans('auth/general.google_login_failed') ], ] ); } $user = User::where('username', $socialUser->getEmail())->first(); if ($user) { \Log::debug('Google user '.$socialUser->getEmail().' found in Snipe-IT'); $user->update([ 'avatar' => $socialUser->avatar, ]); Auth::login($user, true); return redirect()->route('home'); } \Log::debug('Google user '.$socialUser->getEmail().' NOT found in Snipe-IT'); return redirect()->route('login') ->withErrors( [ 'username' => [ trans('auth/general.google_login_failed'), ], ] ); } }