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.

fix(passwordless): require email param (#7717)

Will Hutchinson2f4795779a0b
diff --git a/services/authentication_service/src/api/oauth/passwordless_callback.rs b/services/authentication_service/src/api/oauth/passwordless_callback.rs
index b443445ea6..cc41e6809f 100644
--- a/services/authentication_service/src/api/oauth/passwordless_callback.rs
+++ b/services/authentication_service/src/api/oauth/passwordless_callback.rs
@@ -51,26 +51,27 @@ pub async fn handler(
false
};
- // TODO: once we deploy to prod, remove email being optional
// validate email matches code
- if let Some(email) = params.get("email") {
- let email = urlencoding::decode(email).map_err(|e| {
- tracing::error!(error=?e, "unable to decode email");
- (StatusCode::BAD_REQUEST, "unable to decode email").into_response()
+ let raw_email = params
+ .get("email")
+ .ok_or((StatusCode::BAD_REQUEST, "email required").into_response())?;
+
+ let email = urlencoding::decode(raw_email).map_err(|e| {
+ tracing::error!(error=?e, "unable to decode email");
+ (StatusCode::BAD_REQUEST, "unable to decode email").into_response()
+ })?;
+
+ let passwordless_code = ctx
+ .macro_cache_client
+ .get_passwordless_login_code(&email)
+ .await
+ .map_err(|e| {
+ tracing::error!(error=?e, email=%email, "unable to get passwordless login code");
+ (StatusCode::UNAUTHORIZED, "no passwordless login found").into_response()
})?;
- let passwordless_code = ctx
- .macro_cache_client
- .get_passwordless_login_code(&email)
- .await
- .map_err(|e| {
- tracing::error!(error=?e, email=%email, "unable to get passwordless login code");
- (StatusCode::UNAUTHORIZED, "no passwordless login found").into_response()
- })?;
-
- if passwordless_code != code {
- return Err((StatusCode::UNAUTHORIZED, "invalid code").into_response());
- }
+ if passwordless_code != code {
+ return Err((StatusCode::UNAUTHORIZED, "invalid code").into_response());
}
let passwordless_response = ctx