diff --git a/src/api/v1/onboarding/registration.rs b/src/api/v1/onboarding/registration.rs index 1dd1768..1522b2d 100644 --- a/src/api/v1/onboarding/registration.rs +++ b/src/api/v1/onboarding/registration.rs @@ -7,6 +7,7 @@ use lettre::message::header::ContentType; use lettre::transport::smtp::authentication::Credentials; use lettre::{Message, SmtpTransport, Transport}; use serde::Deserialize; +use serde_json::json; use std::fmt::Debug; use std::str::FromStr; use tracing::{error, info, instrument, warn}; @@ -26,7 +27,7 @@ pub async fn register( Err(e) => { let err = format!("Invalid email address: {e}"); warn!(email = mail.email_address, error = %err); - return (StatusCode::BAD_REQUEST, err); + return (StatusCode::BAD_REQUEST, Json(json!({"error": err}))); } }; info!(email = mail.email_address, "RegistrationRequest received"); @@ -55,12 +56,18 @@ pub async fn register( match mailer.send(&verification_email) { Ok(_) => { info!(email = mail.email_address, "Verification email sent"); - (StatusCode::OK, "Verification email sent".to_string()) + ( + StatusCode::OK, + Json(json!({"msg":"Verification email sent"})), + ) } Err(e) => { let err = format!("Failed to send verification email: {e}"); error!(error = %err); - (StatusCode::INTERNAL_SERVER_ERROR, err) + ( + StatusCode::INTERNAL_SERVER_ERROR, + Json(json!({"error": err})), + ) } } }