diff --git a/core/Controller/TwoFactorApiController.php b/core/Controller/TwoFactorApiController.php index 725001b516a99..713bc0f9c01c3 100644 --- a/core/Controller/TwoFactorApiController.php +++ b/core/Controller/TwoFactorApiController.php @@ -31,9 +31,9 @@ public function __construct( /** * Get two factor authentication provider states * - * @param list $users collection of system user ids + * @param array $users collection of system user ids * - * @return DataResponse + * @return DataResponse>, array{}> * * 200: user/provider states */ @@ -54,9 +54,9 @@ public function state(array $users = []): DataResponse { * Enable two factor authentication providers for specific user * * @param string $user system user identifier - * @param list $providers collection of TFA provider ids + * @param array $providers collection of TFA provider ids * - * @return DataResponse + * @return DataResponse, array{}>|DataResponse * * 200: provider states * 404: user not found @@ -66,24 +66,22 @@ public function state(array $users = []): DataResponse { public function enable(string $user, array $providers = []): DataResponse { $userObject = $this->userManager->get($user); if ($userObject !== null) { - if (is_array($providers)) { - foreach ($providers as $providerId) { - $this->tfManager->tryEnableProviderFor($providerId, $userObject); - } + foreach ($providers as $providerId) { + $this->tfManager->tryEnableProviderFor($providerId, $userObject); } $state = $this->tfRegistry->getProviderStates($userObject); return new DataResponse($state); } - return new DataResponse([], Http::STATUS_NOT_FOUND); + return new DataResponse(null, Http::STATUS_NOT_FOUND); } /** * Disable two factor authentication providers for specific user * * @param string $user system user identifier - * @param list $providers collection of TFA provider ids + * @param array $providers collection of TFA provider ids * - * @return DataResponse + * @return DataResponse, array{}>|DataResponse * * 200: provider states * 404: user not found @@ -93,15 +91,13 @@ public function enable(string $user, array $providers = []): DataResponse { public function disable(string $user, array $providers = []): DataResponse { $userObject = $this->userManager->get($user); if ($userObject !== null) { - if (is_array($providers)) { - foreach ($providers as $providerId) { - $this->tfManager->tryDisableProviderFor($providerId, $userObject); - } + foreach ($providers as $providerId) { + $this->tfManager->tryDisableProviderFor($providerId, $userObject); } $state = $this->tfRegistry->getProviderStates($userObject); return new DataResponse($state); } - return new DataResponse([], Http::STATUS_NOT_FOUND); + return new DataResponse(null, Http::STATUS_NOT_FOUND); } }