diff --git a/app/Http/Controllers/ApiKeyController.php b/app/Http/Controllers/ApiKeyController.php index 0975df9..d25602c 100644 --- a/app/Http/Controllers/ApiKeyController.php +++ b/app/Http/Controllers/ApiKeyController.php @@ -21,6 +21,21 @@ class ApiKeyController extends Controller ->with('keys', Auth::user()->keys); } + public function adminKeys() + { + if (Auth::user()->hasRole('admin')) + { + return view('dashboard.administration.keys') + ->with('keys', ApiKey::all()); + } + else + { + return redirect() + ->back() + ->with('error', 'You do not have permission to access this page.'); + } + } + /** * Store a newly created resource in storage. * diff --git a/config/adminlte.php b/config/adminlte.php index 35c930a..c0b557c 100755 --- a/config/adminlte.php +++ b/config/adminlte.php @@ -370,6 +370,12 @@ return [ 'url' => '/admin/devtools', 'can' => 'admin.developertools.use', ], + [ + 'text' => 'API Keys', + 'icon' => 'fas fa-user-shield', + 'can' => 'admin.settings.view', + 'route' => 'adminKeys' + ] ], ], [ diff --git a/resources/views/dashboard/administration/keys.blade.php b/resources/views/dashboard/administration/keys.blade.php new file mode 100644 index 0000000..b2e5ef0 --- /dev/null +++ b/resources/views/dashboard/administration/keys.blade.php @@ -0,0 +1,99 @@ +@extends('adminlte::page') + +@section('title', config('app.name') . ' | Key Administration') + +@section('content_header') + +
You can use the key discriminator to identify it's API calls in the logs.
+Here, you can view and manage all API keys created by users in the app. You can't, however, use this page to access someone else's account.
+Name | +Discriminator | +Owner | +Status | +Last Used | +Last Modified | +Actions | +
---|---|---|---|---|---|---|
{{ $key->name }} | +{{ $key->discriminator }} | +{{ $key->user->name }} | +{{ ($key->status == 'disabled') ? 'Revoked' : 'Active' }} | +{{ ($key->last_used == null) ? 'No recent activity' : $key->last_used }} | +{{ $key->updated_at }} | ++ @if ($key->status == 'active') + + @else + + @endif + | +
No API keys have been registered yet.
+