From 2f2ecdb44461830893e6a41edb54d1f9d9ee2df9 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 16 Apr 2021 07:40:28 +0200 Subject: [PATCH] Apply new first and last name restrictions --- src/controllers/account_controller.rs | 5 +++-- src/controllers/settings_controller.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/controllers/account_controller.rs b/src/controllers/account_controller.rs index 9d06c63..c459f9a 100644 --- a/src/controllers/account_controller.rs +++ b/src/controllers/account_controller.rs @@ -9,6 +9,7 @@ use crate::api_data::res_check_security_answers::ResCheckSecurityAnswers; use crate::api_data::res_check_security_questions_exists::ResCheckSecurityQuestionsExists; use crate::api_data::res_get_security_questions::ResGetSecurityQuestions; use crate::api_data::user_mail_address::UserMailAddressAPI; +use crate::constants::accounts_info_policy::{MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_LENGTH}; use crate::constants::PASSWORD_RESET_TOKEN_LENGTH; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::error::ResultBoxError; @@ -55,8 +56,8 @@ pub fn create(r: &mut HttpRequestHandler) -> RequestResult { } let new_account = NewAccount { - first_name: r.post_content("firstName", 3, true)?, - last_name: r.post_content("lastName", 3, true)?, + first_name: r.post_content("firstName", MIN_FIRST_NAME_LENGTH as usize, true)?, + last_name: r.post_content("lastName", MIN_LAST_NAME_LENGTH as usize, true)?, email, password: r.post_string_opt("password", 3, true)?, }; diff --git a/src/controllers/settings_controller.rs b/src/controllers/settings_controller.rs index 3dbc01c..ce9f09b 100644 --- a/src/controllers/settings_controller.rs +++ b/src/controllers/settings_controller.rs @@ -10,6 +10,7 @@ use crate::api_data::notification_settings_api::NotificationSettingsAPI; use crate::api_data::res_create_custom_emoji::ResCreateCustomEmoji; use crate::api_data::security_settings_api::SecuritySettingsAPI; use crate::constants::{conservation_policy, SUPPORTED_LANGUAGES}; +use crate::constants::accounts_info_policy::{MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_LENGTH}; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::general_settings::GeneralSettings; use crate::data::http_request_handler::HttpRequestHandler; @@ -45,8 +46,8 @@ pub fn set_general(r: &mut HttpRequestHandler) -> RequestResult { let new_settings = GeneralSettings { id: r.user_id()?, - first_name: r.post_content("firstName", 3, true)?, - last_name: r.post_content("lastName", 3, true)?, + first_name: r.post_content("firstName", MIN_FIRST_NAME_LENGTH as usize, true)?, + last_name: r.post_content("lastName", MIN_LAST_NAME_LENGTH as usize, true)?, page_status, block_comments: !r.post_bool("allowComments")?, allow_posts_from_friends: r.post_bool("allowPostsFromFriends")?,