diff --git a/app/Http/Controllers/ConnectedAccountController.php b/app/Http/Controllers/ConnectedAccountController.php index 3b59774..9e8e716 100644 --- a/app/Http/Controllers/ConnectedAccountController.php +++ b/app/Http/Controllers/ConnectedAccountController.php @@ -8,6 +8,7 @@ use App\Http\Controllers\Controller; use App\Models\ConnectedAccount; use App\Models\ConnectedAccountVerification; use App\Notifications\VerifyConnectedAccountNotification; +use Illuminate\Contracts\Support\MessageBag; use Illuminate\Support\Facades\Auth; use Laravel\Socialite\Facades\Socialite; @@ -33,7 +34,15 @@ class ConnectedAccountController extends Controller { $this->validateProvider($provider); - $providerUser = Socialite::driver($provider)->user(); + try { + + $providerUser = Socialite::driver($provider)->user(); + + } catch (Exception $e) { + + return redirect(route('login')) + ->with('error',new MessageBag([__('Could not login using that provider. Try again later.')])); + } // check if this account is already linked $connected_account = ConnectedAccount::firstOrNew([ @@ -83,7 +92,7 @@ class ConnectedAccountController extends Controller $user->notify(new VerifyConnectedAccountNotification($verification->id)); return redirect(route('login')) - ->with('status', __('Account already exists. Check your email for a link to login.')); + ->with('status', __('Account already exists. Check your email to connect your accounts.')); } protected function validateProvider($provider): void diff --git a/lang/en.json b/lang/en.json index 4288fef..b596039 100644 --- a/lang/en.json +++ b/lang/en.json @@ -51,7 +51,8 @@ "Token Name": "Token Name", "Permissions": "Permissions", "Profile Information": "Profile Information", - "Account already exists. Check your email for a link to login.": "Account already exists. Check your email for a link to login.", + "Account already exists. Check your email to connect the accounts.": "Account already exists. Check your email to connect the accounts.", + "Could not login using that provider. Try again later.": "Could not login using that provider. Try again later.", "Update your account\\'s profile information and email address.": "Update your account\\'s profile information and email address.", "Photo": "Photo", "Select A New Photo": "Select A New Photo", diff --git a/lang/es.json b/lang/es.json index 42e8d6a..ec65896 100644 --- a/lang/es.json +++ b/lang/es.json @@ -51,7 +51,8 @@ "Token Name": "Nombre del Token", "Permissions": "Permisos", "Profile Information": "Información del Perfil", - "Account already exists. Check your email for a link to login.": "La cuenta ya existe. Revisa tu correo electrónico para un enlace de inicio de sesión.", + "Account already exists. Check your email to connect the accounts.": "La cuenta ya existe. Revisa tu correo electrónico para un enlace de inicio de sesión.", + "Could not login using that provider. Try again later.": "No se pudo iniciar sesión con ese proveedor. Inténtalo nuevamente más tarde.", "Update your account's profile information and email address.": "Actualiza la información de perfil y la dirección de correo electrónico de tu cuenta.", "Photo": "Foto", "Select A New Photo": "Seleccionar una Nueva Foto",