| @@ 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 | ||
| @@ 122-129 (lines=8) @@ | ||
| 119 | ||
| 120 | $service->post( |
|
| 121 | '/set_voot_token', |
|
| 122 | function (Request $request, array $hookData) { |
|
| 123 | AuthUtils::requireUser($hookData, ['vpn-user-portal']); |
|
| 124 | ||
| 125 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 126 | $vootToken = InputValidation::vootToken($request->getPostParameter('voot_token')); |
|
| 127 | ||
| 128 | return new ApiResponse('set_voot_token', $this->storage->setVootToken($userId, $vootToken)); |
|
| 129 | } |
|
| 130 | ); |
|
| 131 | ||
| 132 | $service->post( |
|