Output email in error in case of validation failure
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2023-08-25 15:01:45 +02:00
parent 83c757db6d
commit 71ae2df2d7
5 changed files with 14 additions and 4 deletions

View File

@ -1295,6 +1295,7 @@ dependencies = [
"actix-remote-ip",
"actix-web",
"anyhow",
"base64 0.21.2",
"bcrypt",
"clap",
"diesel",

View File

@ -36,3 +36,4 @@ httpdate = "1.0.2"
zip = "0.6.6"
mime_guess = "2.0.4"
tempfile = "3.7.1"
base64 = "0.21.2"

View File

@ -5,6 +5,7 @@ use crate::extractors::member_extractor::FamilyAndMemberInPath;
use crate::models::{Member, MemberID, PhotoID, Sex};
use crate::services::{members_service, photos_service};
use crate::utils::countries_utils;
use crate::utils::encode_utils::base64_enc;
use actix_multipart::form::tempfile::TempFile;
use actix_multipart::form::MultipartForm;
use actix_web::{web, HttpResponse};
@ -62,8 +63,8 @@ enum MemberControllerErr {
MalformedBirthLastname,
#[error("Malformed email address!")]
MalformedEmailAddress,
#[error("Invalid email address!")]
InvalidEmailAddress,
#[error("Invalid email address (base64={0}) !")]
InvalidEmailAddress(String),
#[error("Malformed phone number!")]
MalformedPhoneNumber,
#[error("Malformed address!")]
@ -132,7 +133,7 @@ impl MemberRequest {
if let Some(mail) = &self.email {
if !mailchecker::is_valid(mail) {
return Err(MemberControllerErr::InvalidEmailAddress.into());
return Err(MemberControllerErr::InvalidEmailAddress(base64_enc(mail)).into());
}
}

View File

@ -0,0 +1,6 @@
use base64::{engine::general_purpose, Engine as _};
/// Encode a base64 string
pub fn base64_enc<T: AsRef<[u8]>>(b: T) -> String {
general_purpose::STANDARD_NO_PAD.encode(b)
}

View File

@ -2,5 +2,6 @@
pub mod countries_utils;
pub mod crypt_utils;
pub mod encode_utils;
pub mod string_utils;
pub mod time_utils;