From e5f6b9e93e0c7143691474432b881c4a17b4c2e1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Feb 2021 15:45:20 +0100 Subject: [PATCH] Update login method --- src/controllers/account_controller.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/controllers/account_controller.rs b/src/controllers/account_controller.rs index 82f57f1..7075369 100644 --- a/src/controllers/account_controller.rs +++ b/src/controllers/account_controller.rs @@ -66,8 +66,13 @@ pub fn create(r: &mut HttpRequestHandler) -> RequestResult { /// Sign in user pub fn login_user(request: &mut HttpRequestHandler) -> RequestResult { - let email = request.post_email("userMail")?; - let password = request.post_string_opt("userPassword", 3, true)?; + // TODO : remove fallbacks + let email = request.post_string_with_fallback("mail", "userMail")?; + let password = request.post_string_with_fallback("password", "userPassword")?; + + if !mailchecker::is_valid(&email) { + request.bad_request("Invalid email!".to_string())?; + } // Authenticate user let token = account_helper::login_user(