Show admin dropdown for admin-access ability (#515)
* Show admin dropdown for admin-access ability closes #509 * Formatting
This commit is contained in:
@@ -22,8 +22,8 @@ users:
|
||||
- id: 2
|
||||
pilot_id: 2
|
||||
name: Test User
|
||||
email: test@phpvms.net
|
||||
password: test
|
||||
email: user@phpvms.net
|
||||
password: user
|
||||
api_key: testuserapikey
|
||||
airline_id: 1
|
||||
rank_id: 1
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# All of the different permissions that can be assigned to roles
|
||||
---
|
||||
- name: admin-access
|
||||
display_name: Administrator
|
||||
display_name: Admin Panel
|
||||
description: Access the admin panel
|
||||
- name: airlines
|
||||
display_name: Airlines
|
||||
|
||||
@@ -30,8 +30,8 @@ class Handler extends ExceptionHandler
|
||||
* A list of the exception types that should not be reported.
|
||||
*/
|
||||
protected $dontReport = [
|
||||
AuthenticationException::class,
|
||||
AuthorizationException::class,
|
||||
//AuthenticationException::class,
|
||||
//AuthorizationException::class,
|
||||
AbstractHttpException::class,
|
||||
IlluminateValidationException::class,
|
||||
ModelNotFoundException::class,
|
||||
@@ -50,36 +50,7 @@ class Handler extends ExceptionHandler
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
if ($request->is('api/*')) {
|
||||
Log::error('API Error', $exception->getTrace());
|
||||
|
||||
if ($exception instanceof AbstractHttpException) {
|
||||
return $exception->getResponse();
|
||||
}
|
||||
|
||||
/*
|
||||
* Not of the HttpException abstract class. Map these into
|
||||
*/
|
||||
|
||||
if ($exception instanceof ModelNotFoundException ||
|
||||
$exception instanceof NotFoundHttpException) {
|
||||
$error = new AssetNotFound($exception);
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
// Custom exceptions should be extending HttpException
|
||||
if ($exception instanceof SymfonyHttpException) {
|
||||
$error = new SymfonyException($exception);
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
// Create the detailed errors from the validation errors
|
||||
if ($exception instanceof IlluminateValidationException) {
|
||||
$error = new ValidationException($exception);
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
$error = new GenericExceptionAbstract($exception);
|
||||
return $error->getResponse();
|
||||
return $this->handleApiError($request, $exception);
|
||||
}
|
||||
|
||||
if ($exception instanceof AbstractHttpException
|
||||
@@ -90,6 +61,51 @@ class Handler extends ExceptionHandler
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle errors in the API
|
||||
*
|
||||
* @param $request
|
||||
* @param \Exception $exception
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
|
||||
*/
|
||||
private function handleApiError($request, Exception $exception)
|
||||
{
|
||||
Log::error('API Error', $exception->getTrace());
|
||||
|
||||
if ($exception instanceof AbstractHttpException) {
|
||||
return $exception->getResponse();
|
||||
}
|
||||
|
||||
/*
|
||||
* Not of the HttpException abstract class. Map these into
|
||||
*/
|
||||
|
||||
if ($exception instanceof ModelNotFoundException || $exception instanceof NotFoundHttpException) {
|
||||
$error = new AssetNotFound($exception);
|
||||
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
// Custom exceptions should be extending HttpException
|
||||
if ($exception instanceof SymfonyHttpException) {
|
||||
$error = new SymfonyException($exception);
|
||||
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
// Create the detailed errors from the validation errors
|
||||
if ($exception instanceof IlluminateValidationException) {
|
||||
$error = new ValidationException($exception);
|
||||
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
$error = new GenericExceptionAbstract($exception);
|
||||
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an authentication exception into an unauthenticated response.
|
||||
*
|
||||
|
||||
390
composer.lock
generated
390
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ class UpdateServiceProvider extends ServiceProvider
|
||||
Route::group([
|
||||
'as' => 'update.',
|
||||
'prefix' => 'update',
|
||||
'middleware' => ['auth', 'ability:admin,admin-access', 'web'],
|
||||
'middleware' => ['web', 'auth', 'ability:admin,admin-access'],
|
||||
'namespace' => 'Modules\Updater\Http\Controllers',
|
||||
], function () {
|
||||
Route::get('/', 'UpdateController@index')->name('index');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM php:7.3-fpm-alpine
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
RUN apk add make gmp-dev
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<div class="icon-background"> {{--110px font-size--}}
|
||||
<i class="fas fa-money-bill-alt icon"></i>
|
||||
</div>
|
||||
<h3 class="header">{{ $user->journal->balance }}</h3>
|
||||
<h3 class="header">{{ optional($user->journal)->balance ?? 0 }}</h3>
|
||||
<h5 class="description">@lang('dashboard.yourbalance')</h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -93,11 +93,11 @@
|
||||
<i class="far fa-user"></i> @lang('common.profile')
|
||||
</a>
|
||||
|
||||
@role('admin')
|
||||
@ability('admin', 'admin-access')
|
||||
<a class="dropdown-item" href="{{ url('/admin') }}">
|
||||
<i class="fas fa-circle-notch"></i> @lang('common.administration')
|
||||
</a>
|
||||
@endrole
|
||||
@endability
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{{ url('/logout') }}">
|
||||
<i class="fas fa-sign-out-alt"></i> @lang('common.logout')
|
||||
|
||||
Reference in New Issue
Block a user