From fe3924f5589a20d2377d8cb0b161128de82a8529 Mon Sep 17 00:00:00 2001 From: Emmanuel Durin Date: Tue, 2 Jan 2024 10:49:37 +0100 Subject: [PATCH 1/2] Splitted OAuth2 provider field and added organization for account creation emails --- AI_tests/test.py | 0 .../RabbitmqAccountCreatedEventSender.java | 17 ++++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 AI_tests/test.py diff --git a/AI_tests/test.py b/AI_tests/test.py new file mode 100644 index 00000000..e69de29b diff --git a/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java b/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java index f64ae41f..a12e987f 100644 --- a/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java +++ b/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java @@ -48,19 +48,22 @@ public void on(AccountCreated event) { if (null != oAuth2ProviderId) { String fullName = user.getFirstName() + " " + user.getLastName(); String email = user.getEmail(); - String provider = oAuth2ProviderId; - sendNewOAuthAccountMessage(fullName, email, provider); + String organization = user.getOrganization(); + String[] providerFields = oAuth2ProviderId.split(";"); + sendNewOAuthAccountMessage(fullName, email, organization, providerFields[0], providerFields[1]); } } - public void sendNewOAuthAccountMessage(String fullName, String email, String provider) { - // beans getting a reference to the sender + public void sendNewOAuthAccountMessage(String fullName, String email, String organization, String providerName, + String providerUid) { JSONObject jsonObj = new JSONObject(); jsonObj.put("uid", UUID.randomUUID()); jsonObj.put("subject", OAUTH2_ACCOUNT_CREATION); - jsonObj.put("username", fullName); // bean - jsonObj.put("email", email); // bean - jsonObj.put("provider", provider); // bean + jsonObj.put("username", fullName); + jsonObj.put("email", email); + jsonObj.put("organization", organization); + jsonObj.put("providerName", providerName); + jsonObj.put("providerUid", providerUid); eventTemplate.convertAndSend("routing-gateway", jsonObj.toString());// send } } \ No newline at end of file From a775118533fac08ba769f2a2a2b5e78e4652451a Mon Sep 17 00:00:00 2001 From: Emmanuel Durin Date: Thu, 11 Jan 2024 09:51:46 +0100 Subject: [PATCH 2/2] Some changes for better consistency of templates and OOB checking --- .../RabbitmqAccountCreatedEventSender.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java b/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java index a12e987f..6f853ce6 100644 --- a/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java +++ b/gateway/src/main/java/org/georchestra/gateway/accounts/events/rabbitmq/RabbitmqAccountCreatedEventSender.java @@ -47,19 +47,28 @@ public void on(AccountCreated event) { final String oAuth2ProviderId = user.getOAuth2ProviderId(); if (null != oAuth2ProviderId) { String fullName = user.getFirstName() + " " + user.getLastName(); + String localUid = user.getUsername(); String email = user.getEmail(); String organization = user.getOrganization(); String[] providerFields = oAuth2ProviderId.split(";"); - sendNewOAuthAccountMessage(fullName, email, organization, providerFields[0], providerFields[1]); + String providerName = ""; + String providerUid = ""; + if(providerFields.length == 2) + { + providerName = providerFields[0]; + providerUid = providerFields[1]; + } + sendNewOAuthAccountMessage(fullName, localUid, email, organization, providerName, providerUid); } } - public void sendNewOAuthAccountMessage(String fullName, String email, String organization, String providerName, - String providerUid) { + public void sendNewOAuthAccountMessage(String fullName, String localUid, String email, String organization, + String providerName, String providerUid) { JSONObject jsonObj = new JSONObject(); jsonObj.put("uid", UUID.randomUUID()); jsonObj.put("subject", OAUTH2_ACCOUNT_CREATION); - jsonObj.put("username", fullName); + jsonObj.put("fullName", fullName); + jsonObj.put("localUid", localUid); jsonObj.put("email", email); jsonObj.put("organization", organization); jsonObj.put("providerName", providerName);