- Fixed AdminController to extend OCP\AppFramework\Controller - Annotations (@NoAdminRequired, @NoCSRFRequired) now work - Proper parent::__construct() call - Added test route /admin/test for debugging - Returns JSON to confirm controller works - Helps diagnose routing vs permission issues - Simplified routes to essential ones only - admin#index and admin#test This should resolve 'Access forbidden' for system admin users. The key fix was extending the proper Controller base class.
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\AnalyticsHub\Controller;
|
|
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\AppFramework\Http\JSONResponse;
|
|
use OCP\IRequest;
|
|
|
|
/**
|
|
* Admin Settings Controller
|
|
*
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
class AdminController extends Controller {
|
|
|
|
private $appName;
|
|
|
|
public function __construct($appName, IRequest $request) {
|
|
parent::__construct($appName, $request);
|
|
$this->appName = $appName;
|
|
}
|
|
|
|
/**
|
|
* Index page - render admin UI
|
|
*
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function index(): TemplateResponse {
|
|
return new TemplateResponse($this->appName, 'admin', [
|
|
'app_name' => $this->appName,
|
|
'version' => '1.0.0',
|
|
'status' => 'testing - admin accessible',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Test route - simple JSON response
|
|
*
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function test(): JSONResponse {
|
|
return new JSONResponse([
|
|
'success' => true,
|
|
'message' => 'Analytics Hub controller is working!',
|
|
'app_name' => $this->appName,
|
|
]);
|
|
}
|
|
}
|