feat:catch error on declined permissions
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\ConnectedAccount;
|
use App\Models\ConnectedAccount;
|
||||||
use App\Models\ConnectedAccountVerification;
|
use App\Models\ConnectedAccountVerification;
|
||||||
use App\Notifications\VerifyConnectedAccountNotification;
|
use App\Notifications\VerifyConnectedAccountNotification;
|
||||||
|
use Illuminate\Contracts\Support\MessageBag;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Laravel\Socialite\Facades\Socialite;
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
|
|
||||||
@@ -33,7 +34,15 @@ class ConnectedAccountController extends Controller
|
|||||||
{
|
{
|
||||||
$this->validateProvider($provider);
|
$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
|
// check if this account is already linked
|
||||||
$connected_account = ConnectedAccount::firstOrNew([
|
$connected_account = ConnectedAccount::firstOrNew([
|
||||||
@@ -83,7 +92,7 @@ class ConnectedAccountController extends Controller
|
|||||||
$user->notify(new VerifyConnectedAccountNotification($verification->id));
|
$user->notify(new VerifyConnectedAccountNotification($verification->id));
|
||||||
|
|
||||||
return redirect(route('login'))
|
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
|
protected function validateProvider($provider): void
|
||||||
|
|||||||
+2
-1
@@ -51,7 +51,8 @@
|
|||||||
"Token Name": "Token Name",
|
"Token Name": "Token Name",
|
||||||
"Permissions": "Permissions",
|
"Permissions": "Permissions",
|
||||||
"Profile Information": "Profile Information",
|
"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.",
|
"Update your account\\'s profile information and email address.": "Update your account\\'s profile information and email address.",
|
||||||
"Photo": "Photo",
|
"Photo": "Photo",
|
||||||
"Select A New Photo": "Select A New Photo",
|
"Select A New Photo": "Select A New Photo",
|
||||||
|
|||||||
+2
-1
@@ -51,7 +51,8 @@
|
|||||||
"Token Name": "Nombre del Token",
|
"Token Name": "Nombre del Token",
|
||||||
"Permissions": "Permisos",
|
"Permissions": "Permisos",
|
||||||
"Profile Information": "Información del Perfil",
|
"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.",
|
"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",
|
"Photo": "Foto",
|
||||||
"Select A New Photo": "Seleccionar una Nueva Foto",
|
"Select A New Photo": "Seleccionar una Nueva Foto",
|
||||||
|
|||||||
Reference in New Issue
Block a user