diff options
author | ramon <ramongomez@us.es> | 2018-04-30 08:58:05 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2018-04-30 08:58:05 +0000 |
commit | 61e5ebd8ebd70eeb1eeed4a1ed75fbd1f4a586eb (patch) | |
tree | 825efed364f25730ea7bb00112725f226dc40f2c | |
parent | 98dedfcce3462eda232e7a6e6a9461f3d4c124a7 (diff) |
#839: Correción en API REST para RemotePC: permitir sesión ilimitada si parámetro {{{deadLine=0}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5763 a21b9725-9963-47de-94b9-378ad31fedc9
-rw-r--r-- | admin/WebConsole/rest/opengnsys-api.yml | 10 | ||||
-rw-r--r-- | admin/WebConsole/rest/remotepc.php | 11 |
2 files changed, 12 insertions, 9 deletions
diff --git a/admin/WebConsole/rest/opengnsys-api.yml b/admin/WebConsole/rest/opengnsys-api.yml index 0c9575a2..fcd4961f 100644 --- a/admin/WebConsole/rest/opengnsys-api.yml +++ b/admin/WebConsole/rest/opengnsys-api.yml @@ -668,10 +668,12 @@ paths: schema: type: object properties: - logoutAt: - description: Time to send a logout operation to the client - type: string - format: date-time + deadLine: + description: Maximum session time, in seconds (0 for unlimited) + type: integer + format: int64 + minimum: 0 + required: [ deadLine ] responses: "200": description: Successful response diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php index 98166391..39224636 100644 --- a/admin/WebConsole/rest/remotepc.php +++ b/admin/WebConsole/rest/remotepc.php @@ -340,7 +340,7 @@ EOD; /* * @brief Store session time (in sec). * @note Route: /ous/:ouid/labs/:labid/clients/:clntid/session, Method: POST - * @param int deadLine maximum time session (in seconds) + * @param int deadLine maximum session time, in seconds (0 for unlimited) * @warning Parameters will be stored in a new "remotepc" table. */ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/session', 'validateApiKey', @@ -365,7 +365,7 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/session', 'validateApiKey', if (filter_var($deadLine, FILTER_VALIDATE_INT) === false) { throw new Exception("Deadline must be integer"); } - if ($deadLine <= 0) { + if ($deadLine < 0) { throw new Exception("Resource unavailable"); } } catch (Exception $e) { @@ -420,11 +420,12 @@ EOD; } # Add power off command at deadline time. $cmd->texto .= " ($clntid, NOW() + INTERVAL $deadLine SECOND, 'poweroff');"; - if ($cmd->Ejecutar()) { + if ($deadLine == 0 or $cmd->Ejecutar()) { // Confirm operation. + $cmd->texto = ""; $response = ""; jsonResponse(200, $response); - } else { + } else { // Error message. $response["message"] = "Database error"; jsonResponse(400, $response); @@ -434,7 +435,7 @@ EOD; $response["message"] = "Client is not reserved"; jsonResponse(400, $response); } - } else { + } else { // Error message. $response["message"] = "Client does not exist"; jsonResponse(404, $response); |