Commit c2e2173e authored by Akhil's avatar Akhil 😶
Browse files

Refactor

parent 888211e8
......@@ -40,16 +40,23 @@ class UserController extends ApiController
$response->setStatus(404);
return $response;
}
$user = $this->userService->getUser($uid);
$this->userService->setEmail($uid, $email);
$this->userService->setQuota($uid, $quota);
$recoveryEmailSuccess = $this->userService->setRecoveryEmail($uid, $recoveryEmail);
if(!$recoveryEmailSuccess) {
return $this->getErrorResponse($response, 'error_setting_recovery', 400);
if(is_null($user)) {
$response->setStatus(404);
return $response;
}
$user->setEMailAddress($email);
$user->setQuota($quota);
$recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail);
if(!$recoveryEmailUpdated) {
return $this->getErrorResponse($response, 'error_setting_recovery', 400);
}
$createdFolder = $this->userService->createUserFolder($uid);
$createdFolder = $this->userService->createUserFolder($uid);
if(!$createdFolder){
return $this->getErrorResponse($response, 'error_creating_user_folder', 500);
}
......
......@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace OCA\EcloudAccounts\Service;
use OCP\IUserManager;
use OCP\IUser;
use OCP\IConfig;
use UnexpectedValueException;
......@@ -46,18 +47,8 @@ class UserService
return $this->userManager->userExists($uid);
}
public function setEmail(string $uid, string $email): void
{
$user = $this->userManager->get($uid);
if (is_null($user)) return;
$user->setEMailAddress($email);
}
public function setQuota(string $uid, string $quota): void
{
$user = $this->userManager->get($uid);
if (is_null($user)) return;
$user->setQuota($quota);
public function getUser(string $uid) : ?IUser {
return $this->userManager->get($uid);
}
public function setRecoveryEmail(string $uid, string $recoveryEmail) : bool {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment