1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Change error page for subscriptions where upgrade is not available

This commit is contained in:
David Bomba 2023-02-01 08:43:32 +11:00
parent 1c664d5960
commit c2e177e13b
6 changed files with 29 additions and 11 deletions

View File

@ -222,7 +222,7 @@ class Handler extends ExceptionHandler
return response()->json(['message'=>'Too many requests'], 429);
// } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
// return response()->json(['message'=>'Fatal error'], 500); //@deprecated
} elseif ($exception instanceof AuthorizationException) {
} elseif ($exception instanceof AuthorizationException && $request->expectsJson()) {
return response()->json(['message'=> $exception->getMessage()], 401);
} elseif ($exception instanceof TokenMismatchException) {
return redirect()

View File

@ -55,4 +55,9 @@ class SubscriptionPlanSwitchController extends Controller
]);
}
public function not_availabe()
{
abort(404, 'ewwo');
}
}

View File

@ -1,14 +1,21 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Requests\ClientPortal\Subscriptions;
use App\Models\Subscription;
use App\Utils\Traits\MakesHash;
use App\Exceptions\Ninja\ClientPortalAuthorizationException;
use Illuminate\Foundation\Http\FormRequest;
class ShowPlanSwitchRequest extends FormRequest
{
use MakesHash;
/**
* Determine if the user is authorized to make this request.
@ -31,4 +38,11 @@ class ShowPlanSwitchRequest extends FormRequest
//
];
}
protected function failedAuthorization()
{
throw new ClientPortalAuthorizationException('Unable to change plans due to a restriction on this product.', 400);
}
}

View File

@ -248,7 +248,7 @@ class WebhookSingle implements ShouldQueue
return $this->entity->client;
}
return false;
return null;
}
public function failed($exception = null)

View File

@ -1,5 +1,5 @@
@extends('portal.ninja2020.layout.error')
@section('title', __('Server Error'))
@section('code', '500')
@section('title', __($title) ?: 'Server Error')
@section('code', __($code) ?: '500')
@section('message', __($message) ?: 'System Error')

View File

@ -481,11 +481,10 @@
@yield('message')
</p>
<a href="{{ app('router')->has('home') ? route('home') : url('/') }}">
<button class="bg-transparent text-grey-darkest font-bold uppercase tracking-wide py-3 px-6 border-2 border-grey-light hover:border-grey rounded-lg">
{{ __('Go Home') }}
</button>
<a class="button-link text-sm mt-2" href="{{ url(request()->getSchemeAndHttpHost() . '/client') }}">
{{ ctrans('texts.back_to', ['url' => parse_url(request()->getHttpHost())['host'] ?? request()->getHttpHost()]) }}
</a>
</div>
</div>