From 8fade65c70569fa4f3616e4b444a1da67002b135 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Tue, 6 Aug 2024 13:05:37 +0530 Subject: [PATCH 01/16] temp MR --- appinfo/routes.php | 1 + lib/Controller/AccountController.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index eeeec68a..3496d5ad 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -28,6 +28,7 @@ return ['routes' => [ ['name' => 'account#index', 'url' => '/accounts/{lang}/signup', 'verb' => 'GET', 'postfix' => 'signwithlang'], ['name' => 'account#index', 'url' => '/accounts/signup', 'verb' => 'GET', 'postfix' => 'signwithoutlang'], ['name' => 'account#create', 'url' => '/accounts/create', 'verb' => 'POST'], + ['name' => 'account#sendemail', 'url' => '/accounts/sendemail', 'verb' => 'GET'], ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], ['name' => 'account#check_username_available', 'url' => '/accounts/check_username_available', 'verb' => 'POST'], diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 7081ba9a..8f3c88ac 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -122,7 +122,15 @@ class AccountController extends Controller { } return $response; } - + /** + * @NoAdminRequired + * @PublicPage + * @NoCSRFRequired + * + **/ + public function sendemail() { + echo 'test'; + } /** * @NoAdminRequired * @PublicPage -- GitLab From a2dba356eecf244b99a716b22242e7849bc4523b Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Tue, 6 Aug 2024 13:11:04 +0530 Subject: [PATCH 02/16] changes --- lib/Controller/AccountController.php | 8 +++++++- lib/Service/UserService.php | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 8f3c88ac..952ee2e0 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -129,7 +129,13 @@ class AccountController extends Controller { * **/ public function sendemail() { - echo 'test'; + $displayname = 'Ronak'; + $username = 'ronak.patel'; + $userEmail = 'eronax59@gmail.com'; + $language = 'en'; + $this->userService->sendWelcomeEmail($displayname, $username, $userEmail, $language); + echo 'sent'; + die; } /** * @NoAdminRequired diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 7cca2d81..8ac542ad 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -172,12 +172,14 @@ class UserService { $sendgridAPIkey = $this->getSendGridAPIKey(); if (empty($sendgridAPIkey)) { + print_r("sendgrid_api_key is missing or empty."); $this->logger->warning("sendgrid_api_key is missing or empty.", ['app' => Application::APP_ID]); return; } $templateIDs = $this->getSendGridTemplateIDs(); if (empty($templateIDs)) { + print_r("welcome_sendgrid_template_ids is missing or empty."); $this->logger->warning("welcome_sendgrid_template_ids is missing or empty.", ['app' => Application::APP_ID]); return; } @@ -194,6 +196,7 @@ class UserService { $email = $this->createSendGridEmail($fromEmail, $fromName, $username, $displayname, $userEmail, $templateID); $this->sendEmailWithSendGrid($email, $sendgridAPIkey); } catch (Throwable $e) { + print_r('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); $this->logger->error('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); } } -- GitLab From e1b2815365960e845595994c7eddf574e19710df Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Tue, 6 Aug 2024 13:14:14 +0530 Subject: [PATCH 03/16] changes --- lib/Service/UserService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 8ac542ad..1f26ec8d 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -173,6 +173,7 @@ class UserService { $sendgridAPIkey = $this->getSendGridAPIKey(); if (empty($sendgridAPIkey)) { print_r("sendgrid_api_key is missing or empty."); + die; $this->logger->warning("sendgrid_api_key is missing or empty.", ['app' => Application::APP_ID]); return; } @@ -180,6 +181,7 @@ class UserService { $templateIDs = $this->getSendGridTemplateIDs(); if (empty($templateIDs)) { print_r("welcome_sendgrid_template_ids is missing or empty."); + die; $this->logger->warning("welcome_sendgrid_template_ids is missing or empty.", ['app' => Application::APP_ID]); return; } @@ -197,6 +199,7 @@ class UserService { $this->sendEmailWithSendGrid($email, $sendgridAPIkey); } catch (Throwable $e) { print_r('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); + die; $this->logger->error('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); } } @@ -235,7 +238,8 @@ class UserService { $response = $sendgrid->send($email, [ CURLOPT_TIMEOUT => 15 ]); if ($response->statusCode() < 200 || $response->statusCode() > 299) { - $this->logger->error("SendGrid API error - Status Code: " . $response->statusCode()); + print_r("SendGrid API error - Status Code: " . $response->statusCode()); + die; } } /** -- GitLab From 5527b96ab5270acc874274be3da4992c5e369d78 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:08:40 +0530 Subject: [PATCH 04/16] temp --- appinfo/routes.php | 1 + lib/Controller/AccountController.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/appinfo/routes.php b/appinfo/routes.php index 3496d5ad..b8d13d5d 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -32,5 +32,6 @@ return ['routes' => [ ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], ['name' => 'account#check_username_available', 'url' => '/accounts/check_username_available', 'verb' => 'POST'], + ['name' => 'account#temp_api_check', 'url' => '/accounts/temp_api_check', 'verb' => 'POST'], ]]; diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 952ee2e0..d4dcb745 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -250,6 +250,19 @@ class AccountController extends Controller { return null; // Validation passed } + /** + * Check if a username is available. + * + * @NoAdminRequired + * @PublicPage + * @NoCSRFRequired + * + * @param string $username The username to check. + * + */ + public function tempApiCheck(string $username) { + echo 'test'; + } /** * Check if a username is available. * -- GitLab From 882c9075969afa74392c7c18d4ff7ddf11e3b18f Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:11:36 +0530 Subject: [PATCH 05/16] temp --- lib/Controller/AccountController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index d4dcb745..2f041959 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -261,7 +261,7 @@ class AccountController extends Controller { * */ public function tempApiCheck(string $username) { - echo 'test'; + echo 'test'; } /** * Check if a username is available. -- GitLab From ce900f74ad9c058de7149fc06a21e9cc164541ec Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:16:54 +0530 Subject: [PATCH 06/16] temp --- appinfo/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index b8d13d5d..22fdc165 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -32,6 +32,6 @@ return ['routes' => [ ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], ['name' => 'account#check_username_available', 'url' => '/accounts/check_username_available', 'verb' => 'POST'], - ['name' => 'account#temp_api_check', 'url' => '/accounts/temp_api_check', 'verb' => 'POST'], + ['name' => 'account#temp_api_check', 'url' => '/accounts/temp_api_check', 'verb' => 'GET'], ]]; -- GitLab From 24275ee2a70635d3cfa421a096e34b5041d92cd9 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:17:10 +0530 Subject: [PATCH 07/16] temp --- lib/Controller/AccountController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 2f041959..5f4bc87e 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -261,7 +261,7 @@ class AccountController extends Controller { * */ public function tempApiCheck(string $username) { - echo 'test'; + echo 'test '.$username; } /** * Check if a username is available. -- GitLab From 93a415a911978a1122f29d57e936ed0eaf60c4d2 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:23:00 +0530 Subject: [PATCH 08/16] temp --- lib/Controller/AccountController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 5f4bc87e..e696f61f 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -257,11 +257,10 @@ class AccountController extends Controller { * @PublicPage * @NoCSRFRequired * - * @param string $username The username to check. * */ - public function tempApiCheck(string $username) { - echo 'test '.$username; + public function tempApiCheck() { + echo 'test';die; } /** * Check if a username is available. -- GitLab From eea32420495e28c10c425a98f1ff35add3e72e48 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:24:17 +0530 Subject: [PATCH 09/16] temp --- lib/Controller/AccountController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index e696f61f..d180aa28 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -260,7 +260,8 @@ class AccountController extends Controller { * */ public function tempApiCheck() { - echo 'test';die; + echo 'test'; + die; } /** * Check if a username is available. -- GitLab From 6ab13b24c6030e864920a08aed3037c875ec4bb0 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:31:07 +0530 Subject: [PATCH 10/16] usernam issue --- lib/Controller/AccountController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index d180aa28..b63562c7 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -260,8 +260,16 @@ class AccountController extends Controller { * */ public function tempApiCheck() { - echo 'test'; - die; + try { + $username = 'ronakp1'; + if($this->userService->isUsernameTaken($username)) { + echo 'username taken'; + } else { + echo 'username nottaken'; + } + } catch (Exception $e) { + echo 'username exception issue. '.$e->getMessage(); + } } /** * Check if a username is available. -- GitLab From c08b9c3ee26b4ee3c8617c854863ea2f7686f516 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 01:44:00 +0530 Subject: [PATCH 11/16] usernam issue --- lib/Service/UserService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 1f26ec8d..2da16516 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -406,7 +406,9 @@ class UserService { $headers = [ "Authorization: Bearer $token" ]; - + $this->logger->error('url: '.$url); + $this->logger->error("Authorization: Bearer $token"); + $this->curl->get($url, [], $headers); $statusCode = $this->curl->getLastStatusCode(); -- GitLab From cd7b48ea2539b81e4791907967d372325cbd3c06 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 18:20:04 +0530 Subject: [PATCH 12/16] chagne temp --- appinfo/routes.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 22fdc165..90b0f6f7 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -28,10 +28,8 @@ return ['routes' => [ ['name' => 'account#index', 'url' => '/accounts/{lang}/signup', 'verb' => 'GET', 'postfix' => 'signwithlang'], ['name' => 'account#index', 'url' => '/accounts/signup', 'verb' => 'GET', 'postfix' => 'signwithoutlang'], ['name' => 'account#create', 'url' => '/accounts/create', 'verb' => 'POST'], - ['name' => 'account#sendemail', 'url' => '/accounts/sendemail', 'verb' => 'GET'], ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], - ['name' => 'account#check_username_available', 'url' => '/accounts/check_username_available', 'verb' => 'POST'], - ['name' => 'account#temp_api_check', 'url' => '/accounts/temp_api_check', 'verb' => 'GET'], + ['name' => 'account#validate_fields', 'url' => '/accounts/validate_fields', 'verb' => 'POST'], ]]; -- GitLab From 00cbf1b0236c1c65088c1074f0717e16bd63fa41 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 18:20:52 +0530 Subject: [PATCH 13/16] chagne temp --- appinfo/routes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/appinfo/routes.php b/appinfo/routes.php index 90b0f6f7..30d2e37b 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -31,5 +31,6 @@ return ['routes' => [ ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], ['name' => 'account#validate_fields', 'url' => '/accounts/validate_fields', 'verb' => 'POST'], + ['name' => 'account#temp_api_check', 'url' => '/accounts/temp_api_check', 'verb' => 'GET'], ]]; -- GitLab From 0a7485d3f2a4a470e767c04714fc6525e7fe7093 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 31 Oct 2024 18:22:43 +0530 Subject: [PATCH 14/16] chagne temp --- lib/Controller/AccountController.php | 15 --------------- lib/Service/UserService.php | 13 ++----------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 5bb48a0a..30c964f3 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -128,21 +128,6 @@ class AccountController extends Controller { } return $response; } - /** - * @NoAdminRequired - * @PublicPage - * @NoCSRFRequired - * - **/ - public function sendemail() { - $displayname = 'Ronak'; - $username = 'ronak.patel'; - $userEmail = 'eronax59@gmail.com'; - $language = 'en'; - $this->userService->sendWelcomeEmail($displayname, $username, $userEmail, $language); - echo 'sent'; - die; - } /** * @NoAdminRequired * @PublicPage diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 2da16516..7cca2d81 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -172,16 +172,12 @@ class UserService { $sendgridAPIkey = $this->getSendGridAPIKey(); if (empty($sendgridAPIkey)) { - print_r("sendgrid_api_key is missing or empty."); - die; $this->logger->warning("sendgrid_api_key is missing or empty.", ['app' => Application::APP_ID]); return; } $templateIDs = $this->getSendGridTemplateIDs(); if (empty($templateIDs)) { - print_r("welcome_sendgrid_template_ids is missing or empty."); - die; $this->logger->warning("welcome_sendgrid_template_ids is missing or empty.", ['app' => Application::APP_ID]); return; } @@ -198,8 +194,6 @@ class UserService { $email = $this->createSendGridEmail($fromEmail, $fromName, $username, $displayname, $userEmail, $templateID); $this->sendEmailWithSendGrid($email, $sendgridAPIkey); } catch (Throwable $e) { - print_r('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); - die; $this->logger->error('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); } } @@ -238,8 +232,7 @@ class UserService { $response = $sendgrid->send($email, [ CURLOPT_TIMEOUT => 15 ]); if ($response->statusCode() < 200 || $response->statusCode() > 299) { - print_r("SendGrid API error - Status Code: " . $response->statusCode()); - die; + $this->logger->error("SendGrid API error - Status Code: " . $response->statusCode()); } } /** @@ -406,9 +399,7 @@ class UserService { $headers = [ "Authorization: Bearer $token" ]; - $this->logger->error('url: '.$url); - $this->logger->error("Authorization: Bearer $token"); - + $this->curl->get($url, [], $headers); $statusCode = $this->curl->getLastStatusCode(); -- GitLab From fa05581ab43f67162d4a5009e6624edb0aac6c5f Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Fri, 1 Nov 2024 10:07:40 +0530 Subject: [PATCH 15/16] die added --- lib/Controller/AccountController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 30c964f3..a96c7990 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -279,6 +279,7 @@ class AccountController extends Controller { } catch (Exception $e) { echo 'username exception issue. '.$e->getMessage(); } + die; } /** * Check if a username is available. -- GitLab From 14204291d47ebc997bc9788864ba6f1fa1f47835 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Fri, 1 Nov 2024 10:41:56 +0530 Subject: [PATCH 16/16] added more usernams for test --- lib/Controller/AccountController.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index a96c7990..05a3096a 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -270,16 +270,17 @@ class AccountController extends Controller { */ public function tempApiCheck() { try { - $username = 'ronakp1'; - if($this->userService->isUsernameTaken($username)) { - echo 'username taken'; - } else { - echo 'username nottaken'; + $usernames = ['ronakp1', 'ronakp2', 'ronakp3']; + foreach ($usernames as $username) { + if ($this->userService->isUsernameTaken($username)) { + echo $username . ' username taken
'; + } else { + echo $username . ' username is not taken
'; + } } } catch (Exception $e) { - echo 'username exception issue. '.$e->getMessage(); + echo 'Username exception issue: ' . $e->getMessage(); } - die; } /** * Check if a username is available. -- GitLab