|
31 | 31 | use OCA\UserSQL\Constant\DB; |
32 | 32 | use OCA\UserSQL\Constant\Opt; |
33 | 33 | use OCA\UserSQL\Crypto\IPasswordAlgorithm; |
| 34 | +use OCA\UserSQL\Crypto\Param\ChoiceParam; |
| 35 | +use OCA\UserSQL\Crypto\Param\IntParam; |
34 | 36 | use OCA\UserSQL\Platform\PlatformFactory; |
35 | 37 | use OCA\UserSQL\Properties; |
36 | 38 | use OCP\AppFramework\Controller; |
@@ -77,8 +79,7 @@ class SettingsController extends Controller |
77 | 79 | public function __construct( |
78 | 80 | $appName, IRequest $request, ILogger $logger, IL10N $localization, |
79 | 81 | Properties $properties, Cache $cache |
80 | | - ) |
81 | | - { |
| 82 | + ) { |
82 | 83 | parent::__construct($appName, $request); |
83 | 84 | $this->appName = $appName; |
84 | 85 | $this->logger = $logger; |
@@ -267,13 +268,23 @@ private function validateCryptoParams() |
267 | 268 | $reqParam = $this->request->getParam( |
268 | 269 | "opt-crypto_param_" . $i, null |
269 | 270 | ); |
270 | | - $cryptoParam = $configuration[$i]; |
271 | | - |
272 | | - if (is_null($reqParam) || $reqParam < $cryptoParam->min |
273 | | - || $reqParam > $cryptoParam->max |
274 | | - ) { |
| 271 | + if (is_null($reqParam)) { |
275 | 272 | return false; |
276 | 273 | } |
| 274 | + |
| 275 | + $cryptoParam = $configuration[$i]; |
| 276 | + switch ($cryptoParam->type) { |
| 277 | + case ChoiceParam::TYPE: |
| 278 | + if (!in_array($reqParam, $cryptoParam->choices)) { |
| 279 | + return false; |
| 280 | + } |
| 281 | + break; |
| 282 | + case IntParam::TYPE: |
| 283 | + if ($reqParam < $cryptoParam->min || $reqParam > $cryptoParam->max) { |
| 284 | + return false; |
| 285 | + } |
| 286 | + break; |
| 287 | + } |
277 | 288 | } |
278 | 289 |
|
279 | 290 | return true; |
|
0 commit comments