Fall back when Parcel2Go profile scope is denied
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s
This commit is contained in:
@@ -46,11 +46,11 @@ class DashboardController extends Controller
|
||||
$shippingConfig = $settings->for('parcel2go');
|
||||
if ($isAdmin && filled($shippingConfig['client_id'] ?? null) && filled($shippingConfig['client_secret'] ?? null) && filled($shippingConfig['auth_url'] ?? null)) {
|
||||
try {
|
||||
$parcel2Go->verifyCredentials();
|
||||
if ($parcel2Go->hasScope('my-profile')) {
|
||||
$shipments = array_slice($parcel2Go->fetch('me/orders/detail')['Orders'] ?? [], 0, 4);
|
||||
$shippingStatus = 'Live account';
|
||||
} else {
|
||||
$parcel2Go->verifyCredentials();
|
||||
$shippingStatus = 'Quotes available';
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
|
||||
@@ -15,6 +15,7 @@ class ShippingController extends Controller
|
||||
{
|
||||
abort_unless($request->user()->role === 'admin', 403);
|
||||
try {
|
||||
$parcel2Go->verifyCredentials();
|
||||
$account = [];
|
||||
$balance = [];
|
||||
$orders = [];
|
||||
@@ -31,8 +32,9 @@ class ShippingController extends Controller
|
||||
$profileNotice = 'Parcel2Go connected, but account history is unavailable. Check that this client has my-profile access.';
|
||||
}
|
||||
} else {
|
||||
$parcel2Go->verifyCredentials();
|
||||
$profileNotice = 'Parcel2Go connected for quotes and collections. Add my-profile access in Parcel2Go to show account history and labels.';
|
||||
$profileNotice = $parcel2Go->scopeWasReduced()
|
||||
? 'Parcel2Go rejected the selected API access. Basic shipping access works, but account history and labels need my-profile permission for this client.'
|
||||
: 'Parcel2Go connected for quotes and collections. Add my-profile access in Parcel2Go to show account history and labels.';
|
||||
}
|
||||
|
||||
return view('shipping', compact('account', 'balance', 'orders', 'profileAvailable', 'profileNotice') + [
|
||||
|
||||
Reference in New Issue
Block a user