Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

Refactor

parent 888211e8
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -41,15 +41,22 @@ class UserController extends ApiController
            return $response; 
        }

        $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);
        $user = $this->userService->getUser($uid);
        
        if(is_null($user)) {
            $response->setStatus(404);
            return $response;
        }
        $createdFolder = $this->userService->createUserFolder($uid);

        $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);
        if(!$createdFolder){ 
            return $this->getErrorResponse($response, 'error_creating_user_folder', 500);
        }
+3 −12
Original line number Diff line number Diff line
@@ -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 {