Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(users): email a sign up contact address to request for invitation (#15358)
Mani Chandra7f0ad934c830
diff --git a/config/config.example.toml b/config/config.example.tomlindex 824808a624..f994a0d9b5 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -692,6 +692,7 @@ password_lock_duration_in_secs = 1800 # Lock time. The failed attempt count alsoforgot_password_max_attempts = 5 # Forgot password requests allowed per email within the windowforgot_password_attempts_window_in_secs = 1800 # Window for forgot password requests. It starts with the first requestsignup_disabled = false # Whether to reject self-serve sign ups (magic link and password)+signup_contact_email = "[email protected]" # Address shown to unknown emails that request a magic link while sign up is disabled[oidc.key.k1]kid = "" # Key ID used to identify the signing key in JWKS and JWT headers (Generate using: openssl rand -hex 16)diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 1a1fd59775..f35300de20 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -256,6 +256,7 @@ base_url = "https://integ.hyperswitch.io"force_two_factor_auth = falseforce_cookies = falsesignup_disabled = false+signup_contact_email = "[email protected]"accept_password_on_signup_with_merchant_id = falseinternal_merchant_id = "juspay000"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 802edda708..78c21f3a9f 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -269,6 +269,7 @@ base_url = "https://live.hyperswitch.io"force_two_factor_auth = trueforce_cookies = falsesignup_disabled = true+signup_contact_email = "[email protected]"accept_password_on_signup_with_merchant_id = falseinternal_merchant_id = "juspay000"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 7733b5ace0..e9abcd9b6a 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -265,6 +265,7 @@ base_url = "https://app.hyperswitch.io"force_two_factor_auth = falseforce_cookies = falsesignup_disabled = true+signup_contact_email = "[email protected]"accept_password_on_signup_with_merchant_id = falseinternal_merchant_id = "juspay000"diff --git a/config/development.toml b/config/development.tomlindex 0607e1176c..e006fdcdf2 100644--- a/config/development.toml+++ b/config/development.toml@@ -588,6 +588,7 @@ base_url = "http://localhost:8080"force_two_factor_auth = falseforce_cookies = falsesignup_disabled = false+signup_contact_email = "[email protected]"accept_password_on_signup_with_merchant_id = trueinternal_merchant_id = "juspay000"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 80a5858a50..595d5e594f 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -133,6 +133,7 @@ base_url = "http://localhost:9000"force_two_factor_auth = falseforce_cookies = falsesignup_disabled = false+signup_contact_email = "[email protected]"accept_password_on_signup_with_merchant_id = trueinternal_merchant_id = "juspay000"diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex 1cf73e55fc..379011227d 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -1030,6 +1030,7 @@ pub struct UserSettings {pub forgot_password_max_attempts: u16,pub forgot_password_attempts_window_in_secs: i64,pub signup_disabled: bool,+ pub signup_contact_email: String,}#[derive(Debug, Clone, Default, Deserialize)]diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rsindex 1c0ca7367f..2d709f1139 100644--- a/crates/router/src/core/user.rs+++ b/crates/router/src/core/user.rs@@ -403,9 +403,29 @@ pub async fn connect_account(.unwrap_or(false){if state.conf.user.signup_disabled {+ let theme = theme_utils::get_theme_using_optional_theme_id(&state, theme_id).await?;++ let email_contents = email_types::SignupContact {+ recipient_email: user_email,+ contact_email: state.conf.user.signup_contact_email.clone(),+ theme_config: theme+ .map(|theme| theme.email_config())+ .unwrap_or(state.conf.theme.email_config.clone()),+ };++ let send_email_result = state+ .email_client+ .compose_and_send_email(+ user_utils::get_base_url(&state),+ Box::new(email_contents),+ state.conf.proxy.https_url.as_ref(),+ )+ .await;+ logger::info!(?send_email_result);+return Ok(ApplicationResponse::Json(user_api::ConnectAccountResponse {- is_email_sent: true,+ is_email_sent: send_email_result.is_ok(),user_id: String::new(),},));diff --git a/crates/router/src/services/email/assets/signup_contact.html b/crates/router/src/services/email/assets/signup_contact.htmlnew file mode 100644index 0000000000..fbf4660951--- /dev/null+++ b/crates/router/src/services/email/assets/signup_contact.html@@ -0,0 +1,135 @@+<!DOCTYPE html>+<html lang="en">++<head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />+ <title>Sign up for {entity_name}</title>+</head>+++<body style="+ background-color: #f8f9fb; /*outer wrapper*/+ height: 100%;+ font-family: Arial, Helvetica, sans-serif;+ ">+ <div style="+ width: 100%;+ margin: auto;+ text-align: center;+ background-color: #f8f9fb; /*outer wrapper*/+ ">+ <table style="text-align: center; width: 100%">+ <tr>+ <td style="height: 6px"></td>+ </tr>+ <tr>+ <td style="text-align: center">+ <table style="+ background-color: {background_color};+ text-align: center;+ max-width: 55%;+ margin: auto;+ ">+ <tr>+ <td style="height: 20px"></td>+ </tr>+ <tr>+ <td>+ <table style="width: 100%">+ <tr>+ <td style="text-align: center">+ <img src={entity_logo_url} alt={entity_name} style="+ text-align: center;+ height: auto;+ width: 4rem;+ " />+ </td>+ </tr>+ </table>+ </td>+ </tr>+ <tr>+ <td style="height: 40px"></td>+ </tr>+ <tr>+ <td style="+ font-size: 2.02rem;+ font-weight: 600;+ line-height: 2.5rem;+ color: {foreground_color};+ min-width: 550px;+ ">+ Sign up for {entity_name}+ </td>+ </tr>+ <tr>+ <td style="height: 10px"></td>+ </tr>+ <tr>+ <td style="+ color: {foreground_color};+ opacity:0.8;+ width: 50%;+ font-size: 1.02rem;+ font-weight: 400;+ line-height: 1.4rem;+ min-width: 300px;+ ">+ <table style="+ width: 50%;+ min-width: 350px;+ text-align: center;+ margin: auto;+ ">+ <tr>+ <td>+ The signup for {entity_name} is invite-only. To activate+ your account please drop an email to {contact_email}+ </td>+ </tr>+ </table>+ </td>+ </tr>+ <tr>+ <td style="height: 30px"></td>+ </tr>+ <tr>+ <td style="+ color: {foreground_color};+ opacity:0.8;+ width: 50%;+ font-size: 1.02rem;+ font-weight: 400;+ line-height: 1.4rem;+ min-width: 300px;+ ">+ <table style="+ width: 50%;+ min-width: 500px;+ text-align: center;+ margin: auto;+ ">+ <tr>+ <td>+ If you didn’t request this, you can ignore this email.+ </td>+ </tr>+ </table>+ </td>+ </tr>+ <tr>+ <td style="height: 70px"></td>+ </tr>+ </table>+ </td>+ </tr>+ <tr>+ <td style="height: 6px"></td>+ </tr>+ </table>+ </div>+</body>++</html>diff --git a/crates/router/src/services/email/types.rs b/crates/router/src/services/email/types.rsindex e34eb3d989..4533866440 100644--- a/crates/router/src/services/email/types.rs+++ b/crates/router/src/services/email/types.rs@@ -93,6 +93,13 @@ pub enum EmailBody {background_color: String,foreground_color: String,},+ SignupContact {+ contact_email: String,+ entity_name: String,+ entity_logo_url: String,+ background_color: String,+ foreground_color: String,+ },AnalyticsReport {report_name: String,noun: String,@@ -285,6 +292,22 @@ Email : {user_email}foreground_color = foreground_color)}+ EmailBody::SignupContact {+ contact_email,+ entity_name,+ entity_logo_url,+ background_color,+ foreground_color,+ } => {+ format!(+ include_str!("assets/signup_contact.html"),+ contact_email = contact_email,+ entity_name = entity_name,+ entity_logo_url = entity_logo_url,+ background_color = background_color,+ foreground_color = foreground_color+ )+ }EmailBody::AnalyticsReport {report_name,noun,@@ -769,6 +792,35 @@ impl EmailData for WelcomeToCommunity {}}+pub struct SignupContact {+ pub recipient_email: domain::UserEmail,+ pub contact_email: String,+ pub theme_config: EmailThemeConfig,+}++#[async_trait::async_trait]+impl EmailData for SignupContact {+ async fn get_email_data(&self, _base_url: &str) -> CustomResult<EmailContents, EmailError> {+ let body = html::get_html_body(EmailBody::SignupContact {+ contact_email: self.contact_email.clone(),+ entity_name: self.theme_config.entity_name.clone().into_inner(),+ entity_logo_url: self+ .theme_config+ .entity_logo_url+ .get_string_repr()+ .to_string(),+ background_color: self.theme_config.background_color.clone().into_inner(),+ foreground_color: self.theme_config.foreground_color.clone().into_inner(),+ });++ Ok(EmailContents {+ subject: format!("Sign up for {}", self.theme_config.entity_name.as_str()),+ body: external_services::email::IntermediateString::new(body),+ recipients: self.recipient_email.clone().into_inner().into(),+ })+ }+}+pub struct RoleDeleted {pub recipient_email: domain::UserEmail,pub user_name: domain::UserName,