Browse Source

doCameraOperation: a failed credential check returns status "error"

CMD 3 for a camera (the editor's "Set credentials" button) set
status "ok" before the ONVIF check. When the check failed (wrong
credentials, unreachable camera, unusable reply), the page saw "ok",
reloaded the list and never showed the message. The two failure
branches now set status "error", so the reason is shown.

Tested through the real ajax_asm.php / web.php login (users table and
session id) with the editor's request (UID, SID, CID=5, UU, PP, AU,
CMD=3):
- camera unreachable: error, "GetCapabilities: Communication error
  (Failed to connect to ... port 8080 ...)"
- fake camera, good: ok, credentials and stream stored
- fake camera, HTML 401 page: error, "GetVideoSources: Communication
  error (HTTP 401: reply is not a SOAP envelope)"
- wrong SID: redirected (302)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/2/head
Claude 2 hours ago
parent
commit
b43f159cc7
Failed to extract signature
  1. 2
      lib/controller/doCameraOperation.php

2
lib/controller/doCameraOperation.php

@ -306,9 +306,11 @@
$QS = "UPDATE cameras SET access_login='$EUser', access_pass='$EPass', auth_mode={$AUTH}, ptz_token='{$Eptz}', `status`=1 WHERE id={$CameraID}";
$DATABASE->Query( $QS, false );
} else {
$Data['status'] = 'error'; // the page shows msg only when status is not 'ok' (a failed check was silent)
$Data['msg'] = 'Camera was added.<br/>However provided Credentials are Wrong! ['.$EUser.']:['.$EPass.']';
};
} catch( Throwable $e ){ // PHP 8 Errors too: an uncaught Error ended the request without an answer
$Data['status'] = 'error';
$Data['msg'] = 'Provided Credentials are Wrong! ['.$EUser.']:['.$EPass.']<br/>'.htmlspecialchars( $e->getMessage() );
};
} else {

Loading…
Cancel
Save