| @@ 39-54 (lines=16) @@ | ||
| 36 | $this->storage = $storage; |
|
| 37 | } |
|
| 38 | ||
| 39 | public function init(Service $service) |
|
| 40 | { |
|
| 41 | $service->get( |
|
| 42 | '/log', |
|
| 43 | function (Request $request, array $hookData) { |
|
| 44 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 45 | ||
| 46 | $dateTime = InputValidation::dateTime($request->getQueryParameter('date_time')); |
|
| 47 | $ipAddress = InputValidation::ipAddress($request->getQueryParameter('ip_address')); |
|
| 48 | ||
| 49 | $logData = $this->storage->getLogEntry($dateTime, $ipAddress); |
|
| 50 | ||
| 51 | return new ApiResponse('log', $logData); |
|
| 52 | } |
|
| 53 | ); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| @@ 54-66 (lines=13) @@ | ||
| 51 | ||
| 52 | $service->post( |
|
| 53 | '/add_system_message', |
|
| 54 | function (Request $request, array $hookData) { |
|
| 55 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 56 | ||
| 57 | $type = InputValidation::messageType($request->getPostParameter('message_type')); |
|
| 58 | ||
| 59 | // we do NOT sanitize or verify message as *everything* is |
|
| 60 | // allowed! It will never be used as-is for showing in the |
|
| 61 | // browser, as the user portal will escape it before showing |
|
| 62 | // and the apps MUST interprete it as "text/plain". |
|
| 63 | $message = $request->getPostParameter('message_body'); |
|
| 64 | ||
| 65 | return new ApiResponse('add_system_message', $this->storage->addSystemMessage($type, $message)); |
|
| 66 | } |
|
| 67 | ); |
|
| 68 | ||
| 69 | $service->post( |
|
| @@ 240-247 (lines=8) @@ | ||
| 237 | ||
| 238 | $service->post( |
|
| 239 | '/set_voot_token', |
|
| 240 | function (Request $request, array $hookData) { |
|
| 241 | AuthUtils::requireUser($hookData, ['vpn-user-portal']); |
|
| 242 | ||
| 243 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 244 | $vootToken = InputValidation::vootToken($request->getPostParameter('voot_token')); |
|
| 245 | $this->storage->setVootToken($userId, $vootToken); |
|
| 246 | ||
| 247 | return new ApiResponse('set_voot_token'); |
|
| 248 | } |
|
| 249 | ); |
|
| 250 | ||