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

Commit 2b2c56d5 authored by theronakpatel's avatar theronakpatel
Browse files

Added IP-Address and Recovery email in API call

parent 3f9037d4
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ class AccountController extends Controller {
		$this->config = $config;
		$this->urlGenerator = $urlGenerator;
		$this->logger = $logger;
		$this->request = $request;
	}

	/**
@@ -159,8 +160,8 @@ class AccountController extends Controller {
			
			$this->session->remove(self::SESSION_USERNAME_CHECK);
			$this->session->remove(self::CAPTCHA_VERIFIED_CHECK);

			$this->userService->addUsernameToCommonDataStore($username);
			$ipAddress = $this->request->getRemoteAddress();
			$this->userService->addUsernameToCommonDataStore($username, $ipAddress, $recoveryEmail);
			$response->setStatus(200);
			$response->setData(['success' => true]);

+6 −2
Original line number Diff line number Diff line
@@ -420,10 +420,12 @@ class UserService {
	 * If the operation fails, an exception will be thrown.
	 *
	 * @param string $username The username to add to the common data store.
	 * @param string $ipAddress IP Address of user
	 * @param string $recoveryEmail A recovery Email of user
	 *
	 * @throws AddUsernameToCommonStoreException If an error occurs while adding the username to the common data store.
	 */
	public function addUsernameToCommonDataStore(string $username) : void {
	public function addUsernameToCommonDataStore(string $username, string $ipAddress, string $recoveryEmail) : void {
		$commonServicesURL = $this->apiConfig['commonServicesURL'];
		$commonApiVersion = $this->apiConfig['commonApiVersion'];

@@ -434,7 +436,9 @@ class UserService {
		$url = $commonServicesURL . $endpoint ;
		
		$params = [
			'username' => $username
			'username' => $username,
			'ipAddress' => $ipAddress,
			'recoveryEmail' => $recoveryEmail
		];

		$token = $this->apiConfig['commonServicesToken'];