diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/notifications/EmailSender.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/notifications/EmailSender.java index 260069f5d0..70400ce9d4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/notifications/EmailSender.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/notifications/EmailSender.java @@ -48,7 +48,7 @@ public class EmailSender { * @throws MailException */ public void sendMail(String to, String subject, String text) { - log.debug("Got request to send email to: {} with subject: {} and text: {}", to, subject, text); + log.debug("Got request to send email to: {} with subject: {}", to, subject); // Don't send an email for local, dev or test environments if (!emailConfig.isEmailEnabled()) { return; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java index 5e7ce19c11..283ca7a7d8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java @@ -53,7 +53,6 @@ public class UserServiceImpl extends BaseService i private final PasswordResetTokenRepository passwordResetTokenRepository; private final PasswordEncoder passwordEncoder; private final EmailSender emailSender; - private final GroupService groupService; private final InviteUserRepository inviteUserRepository; private final UserOrganizationService userOrganizationService; private final ApplicationRepository applicationRepository; @@ -63,6 +62,8 @@ public class UserServiceImpl extends BaseService i private static final String FORGOT_PASSWORD_EMAIL_TEMPLATE = "email/forgotPasswordTemplate.html"; private static final String INVITE_USER_CLIENT_URL_FORMAT = "%s/user/createPassword?token=%s&email=%s"; private static final String FORGOT_PASSWORD_CLIENT_URL_FORMAT = "%s/user/resetPassword?token=%s&email=%s"; + // We default the origin header to the production deployment of the client's URL + private static final String DEFAULT_ORIGIN_HEADER = "https://app.appsmith.com"; @Autowired public UserServiceImpl(Scheduler scheduler, @@ -76,7 +77,6 @@ public class UserServiceImpl extends BaseService i PasswordResetTokenRepository passwordResetTokenRepository, PasswordEncoder passwordEncoder, EmailSender emailSender, - GroupService groupService, InviteUserRepository inviteUserRepository, UserOrganizationService userOrganizationService, ApplicationRepository applicationRepository) { @@ -88,7 +88,6 @@ public class UserServiceImpl extends BaseService i this.passwordResetTokenRepository = passwordResetTokenRepository; this.passwordEncoder = passwordEncoder; this.emailSender = emailSender; - this.groupService = groupService; this.inviteUserRepository = inviteUserRepository; this.userOrganizationService = userOrganizationService; this.applicationRepository = applicationRepository; @@ -281,10 +280,12 @@ public class UserServiceImpl extends BaseService i return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ORIGIN)); } - // Create an invite token for the user. This token is linked to the email ID and the organization to which the user was invited. + // Create an invite token for the user. This token is linked to the email ID and the organization to which the + // user was invited. String token = UUID.randomUUID().toString(); - Mono currentUserMono = sessionUserService.getCurrentUser(); + // Caching the response from sessionUserService because it's re-used multiple times in this flow + Mono currentUserMono = sessionUserService.getCurrentUser().cache(); Mono inviteUserMono = currentUserMono .map(currentUser -> { log.debug("Got request to invite user {} by user: {} for org: {}", @@ -424,7 +425,7 @@ public class UserServiceImpl extends BaseService i public Mono createUser(User user, String originHeader) { if (originHeader == null || originHeader.isBlank()) { // Default to the production link - originHeader = "https://app.appsmith.com"; + originHeader = DEFAULT_ORIGIN_HEADER; } final String finalOriginHeader = originHeader; @@ -462,7 +463,6 @@ public class UserServiceImpl extends BaseService i Map params = new HashMap<>(); params.put("personalOrganizationName", personalOrganizationName); params.put("firstName", savedUser.getName()); - // TODO: Configure this link for each environment. For now, hard-coding it to app.appsmith.com for production params.put("appsmithLink", finalOriginHeader); String emailBody = emailSender.replaceEmailTemplate(WELCOME_USER_EMAIL_TEMPLATE, params); emailSender.sendMail(savedUser.getEmail(), "Welcome to Appsmith", emailBody); diff --git a/app/server/appsmith-server/src/main/resources/application-staging.properties b/app/server/appsmith-server/src/main/resources/application-staging.properties index 84cf71fbb4..9c6c8af343 100644 --- a/app/server/appsmith-server/src/main/resources/application-staging.properties +++ b/app/server/appsmith-server/src/main/resources/application-staging.properties @@ -24,7 +24,7 @@ spring.security.oauth2.client.provider.github.userNameAttribute=login oauth2.allowed-domains= # Segment & Rollbar Properties -segment.writeKey=FIRLqUgMYuTlyS6yqOE2hBGZs5umkWhr +segment.writeKey=B3UBOacfOky4l6dfk5xyR6Dh8vUZYizW com.rollbar.access-token=b91c4d5b9cac444088f4db9216ed6f42 com.rollbar.environment=development