From 9574f5e8091b353983d0d3fef637feac1b792079 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 13 Aug 2023 15:53:22 +0100 Subject: [PATCH] fix: better errors (where appropiate) for skynet address Closes #17 --- src/methods/account_recover.rs | 3 ++- src/methods/account_update.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/methods/account_recover.rs b/src/methods/account_recover.rs index 650c9d5..3c50db5 100644 --- a/src/methods/account_recover.rs +++ b/src/methods/account_recover.rs @@ -34,7 +34,7 @@ pub mod password { if let Some(mail) = &email { if mail.trim().ends_with("@skynet.ie") { // all responses from this are a success - return Ok(json!({"result": "success"}).into()); + return Ok(json!({"result": "error", "error": "Skynet email not permitted."}).into()); } } @@ -51,6 +51,7 @@ pub mod password { // user does not have a different email address set if user_details.mail.trim().ends_with("@skynet.ie") { + // not returning an error here as there is no need to let the person requesting what email the user has return Ok(json!({"result": "success"}).into()); } diff --git a/src/methods/account_update.rs b/src/methods/account_update.rs index 0bb85dc..1e9a144 100644 --- a/src/methods/account_update.rs +++ b/src/methods/account_update.rs @@ -36,7 +36,7 @@ pub async fn submit(mut req: Request) -> tide::Result { // check that any mail is not using @skynet.ie if field == "mail" && value.trim().ends_with("@skynet.ie") { - return Ok(json!({"result": "error", "error": "skynet email not valid contact address"}).into()); + return Ok(json!({"result": "error", "error": "Skynet email not valid contact address"}).into()); } let config = &req.state().config;