| @@ 116-133 (lines=18) @@ | ||
| 113 | // PUT /config/common_names/:commonName set new config for CN |
|
| 114 | $service->put( |
|
| 115 | '/config/common_names/:commonName', |
|
| 116 | function (Request $request, TokenInfo $tokenInfo, $commonName) { |
|
| 117 | Utils::requireScope($tokenInfo, ['admin']); |
|
| 118 | InputValidation::commonName($commonName); |
|
| 119 | ||
| 120 | // we wrap the request body in an CnConfig object to validate |
|
| 121 | // whatever is there |
|
| 122 | $requestCnConfig = new CnConfig(Json::decode($request->getBody())); |
|
| 123 | ||
| 124 | $this->io->writeFile( |
|
| 125 | sprintf('%s/%s', $this->configDir, $commonName), |
|
| 126 | Json::encode($requestCnConfig->toArray()) |
|
| 127 | ); |
|
| 128 | ||
| 129 | $response = new JsonResponse(); |
|
| 130 | $response->setBody(['ok' => true]); |
|
| 131 | ||
| 132 | return $response; |
|
| 133 | } |
|
| 134 | ); |
|
| 135 | } |
|
| 136 | } |
|
| @@ 154-171 (lines=18) @@ | ||
| 151 | ||
| 152 | $service->put( |
|
| 153 | '/config/users/:userId', |
|
| 154 | function (Request $request, TokenInfo $tokenInfo, $userId) { |
|
| 155 | Utils::requireScope($tokenInfo, ['admin']); |
|
| 156 | InputValidation::userId($userId); |
|
| 157 | ||
| 158 | // we wrap the request body in an UserConfig object to validate |
|
| 159 | // whatever is there |
|
| 160 | $requestUserConfig = new UserConfig(Json::decode($request->getBody())); |
|
| 161 | ||
| 162 | $this->io->writeFile( |
|
| 163 | sprintf('%s/%s', $this->configDir, $userId), |
|
| 164 | Json::encode($requestUserConfig->toArray()) |
|
| 165 | ); |
|
| 166 | ||
| 167 | $response = new JsonResponse(); |
|
| 168 | $response->setBody(['ok' => true]); |
|
| 169 | ||
| 170 | return $response; |
|
| 171 | } |
|
| 172 | ); |
|
| 173 | } |
|
| 174 | } |
|