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

Commit 442dc6e2 authored by Akhil's avatar Akhil 🙂
Browse files

Add user to common data store immediately after registration at LDAP

parent a4cab291
Loading
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -8,7 +8,6 @@ namespace OCA\EcloudAccounts\Controller;


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


			$this->userService->setAccountDataLocally($username, $userEmail);
			$this->userService->setAccountDataLocally($username, $userEmail);
			$this->userService->createHMEAlias($username, $userEmail);
			$this->userService->createHMEAlias($username, $userEmail);
@@ -207,8 +208,6 @@ class AccountController extends Controller {
			$this->session->remove(self::SESSION_VERIFIED_USERNAME);
			$this->session->remove(self::SESSION_VERIFIED_USERNAME);
			$this->session->remove(self::SESSION_VERIFIED_DISPLAYNAME);
			$this->session->remove(self::SESSION_VERIFIED_DISPLAYNAME);
			$this->session->remove(self::CAPTCHA_VERIFIED_CHECK);
			$this->session->remove(self::CAPTCHA_VERIFIED_CHECK);
			$ipAddress = $this->request->getRemoteAddress();
			$this->userService->addUsernameToCommonDataStore($username, $ipAddress, $recoveryEmail);


			$response->setStatus(200);
			$response->setStatus(200);
			$response->setData(['success' => true]);
			$response->setData(['success' => true]);
@@ -221,10 +220,6 @@ class AccountController extends Controller {
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$response->setData(['message' => $e->getMessage(), 'success' => false]);
			$response->setData(['message' => $e->getMessage(), 'success' => false]);
			$response->setStatus(400);
			$response->setStatus(400);
		} catch (AddUsernameToCommonStoreException $e) {
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$response->setStatus(200);
			$response->setData(['success' => true]);
		} catch (Exception $e) {
		} catch (Exception $e) {
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$this->logger->logException($e, ['app' => Application::APP_ID]);
			$response->setData(['message' => 'An error occurred while creating your account!', 'success' => false]);
			$response->setData(['message' => 'An error occurred while creating your account!', 'success' => false]);
+4 −1
Original line number Original line Diff line number Diff line
@@ -472,7 +472,10 @@ class UserService {
		$this->curl->post($url, $params, $headers);
		$this->curl->post($url, $params, $headers);


		if ($this->curl->getLastStatusCode() !== 200) {
		if ($this->curl->getLastStatusCode() !== 200) {
			throw new AddUsernameToCommonStoreException("Error adding username '$username' to common data store.");
			$this->logger->logException(
				new AddUsernameToCommonStoreException("Error adding username '$username' to common data store."),
				['app' => Application::APP_ID]
			);
		}
		}
	}
	}