mirror of
https://github.com/dyzulk/trustlab-api.git
synced 2026-01-26 13:22:05 +07:00
fix: allow owner role to access all admin api endpoints and see stats
This commit is contained in:
@@ -18,7 +18,7 @@ class RootCaApiController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->authorizeAdmin();
|
||||
$this->authorizeAdminOrOwner();
|
||||
|
||||
$certificates = CaCertificate::all()->map(function($cert) {
|
||||
$cert->status = $cert->valid_to->isFuture() ? 'valid' : 'expired';
|
||||
@@ -33,7 +33,7 @@ class RootCaApiController extends Controller
|
||||
|
||||
public function renew(Request $request, CaCertificate $certificate)
|
||||
{
|
||||
$this->authorizeAdmin();
|
||||
$this->authorizeAdminOrOwner();
|
||||
|
||||
$days = (int) $request->input('days', 3650);
|
||||
|
||||
@@ -60,10 +60,10 @@ class RootCaApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
protected function authorizeAdmin()
|
||||
protected function authorizeAdminOrOwner()
|
||||
{
|
||||
if (auth()->user()->role !== 'admin') {
|
||||
abort(403, 'Unauthorized action.');
|
||||
if (!auth()->user()->isAdminOrOwner()) {
|
||||
abort(403, 'Unauthorized action. Admin/Owner access required.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user