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); return response()->json(['message'=>'Too many requests'], 429);
// } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) { // } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
// return response()->json(['message'=>'Fatal error'], 500); //@deprecated // 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); return response()->json(['message'=> $exception->getMessage()], 401);
} elseif ($exception instanceof TokenMismatchException) { } elseif ($exception instanceof TokenMismatchException) {
return redirect() 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 <?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; namespace App\Http\Requests\ClientPortal\Subscriptions;
use App\Models\Subscription; use App\Exceptions\Ninja\ClientPortalAuthorizationException;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
class ShowPlanSwitchRequest extends FormRequest class ShowPlanSwitchRequest extends FormRequest
{ {
use MakesHash;
/** /**
* Determine if the user is authorized to make this request. * 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 $this->entity->client;
} }
return false; return null;
} }
public function failed($exception = null) public function failed($exception = null)

View File

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

View File

@ -481,11 +481,10 @@
@yield('message') @yield('message')
</p> </p>
<a href="{{ app('router')->has('home') ? route('home') : url('/') }}"> <a class="button-link text-sm mt-2" href="{{ url(request()->getSchemeAndHttpHost() . '/client') }}">
<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"> {{ ctrans('texts.back_to', ['url' => parse_url(request()->getHttpHost())['host'] ?? request()->getHttpHost()]) }}
{{ __('Go Home') }}
</button>
</a> </a>
</div> </div>
</div> </div>