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

Commit 5668753a authored by Akhil's avatar Akhil 🙂
Browse files

Merge branch 'dev/fix-common-db-sync' into 'main'

Add user to common data store immediately after registration at LDAP

See merge request !211
parents a4cab291 6bffcae0
Loading
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ namespace OCA\EcloudAccounts\Controller;

use Exception;
use OCA\EcloudAccounts\AppInfo\Application;
use OCA\EcloudAccounts\Exception\AddUsernameToCommonStoreException;
use OCA\EcloudAccounts\Exception\LDAPUserCreationException;
use OCA\EcloudAccounts\Exception\RecoveryEmailValidationException;
use OCA\EcloudAccounts\Service\CaptchaService;
@@ -190,7 +189,14 @@ class AccountController extends Controller {
			$userEmail = $username.'@'.$mainDomain;
			$this->userService->registerUser($displayname, $recoveryEmail, $username, $userEmail, $password, $language);
			sleep(5);

			try {
				// Don't want this operation to block the rest of registration logic
				// so we need a nested try-catch
				$ipAddress = $this->request->getRemoteAddress();
				$this->userService->addUsernameToCommonDataStore($username, $ipAddress, $recoveryEmail);
			} catch (\Throwable $e) {
				$this->logger->logException($e, ['app' => Application::APP_ID]);
			}
			$this->userService->setAccountDataLocally($username, $userEmail);
			$this->userService->createHMEAlias($username, $userEmail);
			$this->userService->createNewDomainAlias($username, $userEmail);
@@ -207,8 +213,6 @@ class AccountController extends Controller {
			$this->session->remove(self::SESSION_VERIFIED_USERNAME);
			$this->session->remove(self::SESSION_VERIFIED_DISPLAYNAME);
			$this->session->remove(self::CAPTCHA_VERIFIED_CHECK);
			$ipAddress = $this->request->getRemoteAddress();
			$this->userService->addUsernameToCommonDataStore($username, $ipAddress, $recoveryEmail);

			$response->setStatus(200);
			$response->setData(['success' => true]);
@@ -221,10 +225,6 @@ class AccountController extends Controller {
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$response->setData(['message' => $e->getMessage(), 'success' => false]);
			$response->setStatus(400);
		} catch (AddUsernameToCommonStoreException $e) {
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$response->setStatus(200);
			$response->setData(['success' => true]);
		} catch (Exception $e) {
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$response->setData(['message' => 'An error occurred while creating your account!', 'success' => false]);