Fix code-review findings: ajax error handling, translated comment, docs
- js/index.js: the occ-command ajax call used the wrong jQuery .fail() signature ((response, code) instead of (jqXHR, textStatus, errorThrown)), so any failure printed the literal string "[object Object]" instead of a useful message. - js/index.js: the initial bootstrap call that builds the terminal had no .fail() handler at all - a failure there (expired session/CSRF token, network error, rejected admin check) left #app-content permanently blank with zero diagnostic information. This is exactly what made today's NC34 debugging session harder than it needed to be; now it shows the actual HTTP status/reason in the page. - OccController.php: translated a leftover Dutch comment (missed by the earlier Russian->English pass since it wasn't Russian), and documented why requireAdmin() is intentional defense-in-depth rather than a misunderstanding of the framework: verified against Nextcloud's own SecurityMiddleware source that any controller method without @NoAdminRequired already rejects non-admins by default, so this check (and the original "security fix" commit that added it) was addressing a non-issue for THIS controller specifically. DbController's equivalent check is still genuinely load-bearing - that controller originally shipped with @PublicPage, which does bypass the default protection - so it gets a note explaining the distinction instead. - README: added compatibility matrix rows for 0.4.0 (app id rename to extended_occweb) and 0.4.1 (these fixes), both verified on NC 34.0.4. Deferred to when a test instance exists (tracked, not fixed here): no documented migration path from the old occweb id to extended_occweb for existing installs, OccController's constructor doing expensive work before the (redundant) admin check runs, and js/jquery.js loading unconditionally on NC30-33 where core still provides jQuery. Version bump to 0.4.1.
This commit is contained in:
@@ -162,7 +162,12 @@ class DbController extends Controller
|
||||
|
||||
public function query()
|
||||
{
|
||||
// Check admin privileges
|
||||
// Deliberate defense-in-depth (see the equivalent check in
|
||||
// OccController::requireAdmin() for why it's kept even though
|
||||
// Nextcloud's SecurityMiddleware already enforces this by default
|
||||
// absent @NoAdminRequired) - this one is also the direct fix for
|
||||
// this controller having shipped with @PublicPage originally,
|
||||
// which did bypass that default protection entirely.
|
||||
$user = $this->userSession->getUser();
|
||||
if (!$user) {
|
||||
return new JSONResponse(['error' => 'Not authenticated'], 401);
|
||||
|
||||
Reference in New Issue
Block a user