Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(auth): require a work email for mobile signups; dark-mode-safe email logo (#8019)

juliawest7ef193b0098b
diff --git a/Cargo.lock b/Cargo.lock
index ca4939bb51..b4de1710d0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1973,6 +1973,7 @@ dependencies = [
"foreign_entity",
"fusionauth",
"futures",
+ "generic_email_domains",
"github",
"github_pull_requests",
"gtm_invite",
diff --git a/apps/marketing/src/app/utils/utilMobileSignup.ts b/apps/marketing/src/app/utils/utilMobileSignup.ts
index da2e3c4075..41d7e0c730 100644
--- a/apps/marketing/src/app/utils/utilMobileSignup.ts
+++ b/apps/marketing/src/app/utils/utilMobileSignup.ts
@@ -71,6 +71,9 @@ export const markConversionFired = (email: string | null): void =>
export const isLikelyEmail = (value: string): boolean =>
/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(value);
+/** Must match `SendMobileWelcomeEmailError::PersonalEmail` in the auth service. */
+const WORK_EMAIL_REQUIRED = 'Please use your work email';
+
export type MobileSignupResult = { ok: true } | { ok: false; message: string };
/**
@@ -110,7 +113,16 @@ export const submitMobileSignup = async (
}
if (response.status === 400) {
- return { ok: false, message: 'That email address was not accepted.' };
+ const body = (await response.json().catch(() => null)) as {
+ message?: string;
+ } | null;
+ return {
+ ok: false,
+ message:
+ body?.message === WORK_EMAIL_REQUIRED
+ ? `${WORK_EMAIL_REQUIRED}.`
+ : 'That email address was not accepted.',
+ };
}
if (response.status === 429) {
return { ok: false, message: 'Too many attempts. Please try again later.' };
diff --git a/apps/web/public/macro-email-icon.png b/apps/web/public/macro-email-icon.png
new file mode 100644
index 0000000000..877dee8b0a
Binary files /dev/null and b/apps/web/public/macro-email-icon.png differ
diff --git a/services/authentication_service/Cargo.toml b/services/authentication_service/Cargo.toml
index ea46d231fa..ae295481f8 100644
--- a/services/authentication_service/Cargo.toml
+++ b/services/authentication_service/Cargo.toml
@@ -82,6 +82,7 @@ foreign_entity = { path = "../../crates/foreign_entity" }
favorites = { path = "../../crates/favorites", features = ["postgres"] }
fusionauth = { path = "../../crates/fusionauth" }
futures = { workspace = true }
+generic_email_domains = { path = "../../crates/generic_email_domains" }
gtm_invite = { path = "../../crates/gtm_invite" }
github = { path = "../../crates/github", default-features = false, features = [
"axum",
diff --git a/services/authentication_service/src/api/mobile_welcome_email.rs b/services/authentication_service/src/api/mobile_welcome_email.rs
index 7b5ce3bd9e..e3e675032f 100644
--- a/services/authentication_service/src/api/mobile_welcome_email.rs
+++ b/services/authentication_service/src/api/mobile_welcome_email.rs
@@ -22,6 +22,9 @@ pub enum SendMobileWelcomeEmailError {
#[error("Email is blocked")]
EmailBlocked,
+ #[error("Please use your work email")]
+ PersonalEmail,
+
#[error("Internal error")]
InternalError(#[from] anyhow::Error),
}
@@ -30,7 +33,8 @@ impl IntoResponse for SendMobileWelcomeEmailError {
fn into_response(self) -> Response {
let status_code = match &self {
SendMobileWelcomeEmailError::InvalidEmail
- | SendMobileWelcomeEmailError::EmailBlocked => StatusCode::BAD_REQUEST,
+ | SendMobileWelcomeEmailError::EmailBlocked
+ | SendMobileWelcomeEmailError::PersonalEmail => StatusCode::BAD_REQUEST,
SendMobileWelcomeEmailError::InternalError(_) => StatusCode::INTERNAL_SERVER_ERROR,
};
@@ -91,6 +95,10 @@ pub async fn handler(
return Err(SendMobileWelcomeEmailError::InvalidEmail);
}
+ if is_personal_email(&req.email) {
+ return Err(SendMobileWelcomeEmailError::PersonalEmail);
+ }
+
let lowercase_email = loops_client::normalize_email(&req.email);
// Check if the email is blocked
@@ -164,6 +172,13 @@ pub async fn handler(
Ok(Json(SendMobileWelcomeEmailResponse { sent: true }))
}
+fn is_personal_email(email: &str) -> bool {
+ email
+ .trim()
+ .rsplit_once('@')
+ .is_some_and(|(_, domain)| generic_email_domains::is_generic_email_domain(domain))
+}
+
/// Desktop signup page. The local frontend origin has no `/app` prefix.
fn desktop_signup_url(base: &url::Url) -> String {
let mut url = base.clone();
@@ -197,7 +212,7 @@ fn desktop_email_html(url: &str) -> String {
<tr>
<td bgcolor="#ffffff" style="padding:36px 40px 40px;border:1px solid #e7e7e5;border-radius:12px;">
<a href="https://macro.com" style="text-decoration:none;">
- <img src="https://macro.com/app/macro-email-logo.png" width="36" height="36" alt="Macro" style="display:block;border:0;background-color:#ffffff;" />
+ <img src="https://macro.com/app/macro-email-icon.png" width="48" height="48" alt="Macro" style="display:block;border:0;" />
</a>
<h1 style="margin:36px 0 16px;font-size:28px;line-height:36px;font-weight:600;letter-spacing:-0.5px;color:#222222;">{DESKTOP_EMAIL_SUBJECT}</h1>
<p style="margin:0 0 20px;font-size:16px;line-height:26px;color:#525252;">Macro is a better experience on desktop. Open this link to finish signing up — it only takes a minute.</p>
@@ -243,4 +258,13 @@ mod tests {
assert!(html.contains(r#"href="https://macro.com/app/signup""#));
assert!(html.contains(DESKTOP_EMAIL_SUBJECT));
}
+
+ #[test]
+ fn personal_email_providers_are_rejected() {
+ assert!(is_personal_email("[email protected]"));
+ assert!(is_personal_email(" [email protected] "));
+ assert!(is_personal_email("[email protected]"));
+ assert!(!is_personal_email("[email protected]"));
+ assert!(!is_personal_email("[email protected]"));
+ }
}