/** * Creates a user account. * The username can be an email or a mobile. * * @param string $uniqueness * @param string $username * @param string $password * @param string[] $roles * * @throws EmptyPasswordInternalException * @throws InvalidUsernameInternalException * @throws ExistentUsernameInternalException */ public function create($uniqueness, $username, $password, $roles) { if ($password === '') { $this->deleteUniquenessSharedWorker->delete($uniqueness); throw new EmptyPasswordInternalException(); } try { $this->createMobileProfileSharedWorker->create($uniqueness, $username); } catch (InvalidNumberSharedException $e) { try { $this->createInternetProfileSharedWorker->create($uniqueness, $username); } catch (InvalidEmailSharedException $e) { $this->deleteUniquenessSharedWorker->delete($uniqueness); throw new InvalidUsernameInternalException(); } catch (ExistentEmailSharedException $e) { $this->deleteUniquenessSharedWorker->delete($uniqueness); throw new ExistentUsernameInternalException(); } } catch (ExistentNumberSharedException $e) { $this->deleteUniquenessSharedWorker->delete($uniqueness); throw new ExistentUsernameInternalException(); } $this->createPrivilegeProfileSharedWorker->create($uniqueness, $roles); $this->createInvitationProfileSharedWorker->create($uniqueness); $this->createAuthenticationProfileSharedWorker->create($uniqueness, $password); $this->createCreditProfileSharedWorker->create($uniqueness, 0); $this->createRechargeCardProfileSharedWorker->create($uniqueness, 0, []); $this->createInfoSmsProfileSharedWorker->create($uniqueness, 0); }
/** * Deletes a user account. * * @param string $uniqueness * * @throws NonExistentIdSharedException */ public function delete($uniqueness) { try { $this->deleteUniquenessSharedWorker->delete($uniqueness); } catch (NonExistentIdSharedException $e) { throw $e; } try { $this->deleteMobileProfileSharedWorker->delete($uniqueness); } catch (NonExistentMobileProfileSharedException $e) { } try { $this->deleteInternetProfileSharedWorker->delete($uniqueness); } catch (NonExistentInternetProfileSharedException $e) { } $this->deletePrivilegeProfileSharedWorker->delete($uniqueness); $this->deleteAuthenticationProfileSharedWorker->delete($uniqueness); $this->deleteCreditProfileSharedWorker->delete($uniqueness); $this->deleteRechargeCardProfileSharedWorker->delete($uniqueness); $this->deleteInfoSmsProfileSharedWorker->delete($uniqueness); $this->logOperationInternalWorker->logDeletion($uniqueness); }