From 2b2c56d51831ae38158a0e1787bd00eeb694071d Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Wed, 24 Jul 2024 13:42:01 +0530 Subject: [PATCH] Added IP-Address and Recovery email in API call --- lib/Controller/AccountController.php | 5 +++-- lib/Service/UserService.php | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 6d78e275..48d5117f 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -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]); diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 8fb5b220..fea70cb8 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -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']; -- GitLab