Output email in error in case of validation failure
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
83c757db6d
commit
71ae2df2d7
1
geneit_backend/Cargo.lock
generated
1
geneit_backend/Cargo.lock
generated
@ -1295,6 +1295,7 @@ dependencies = [
|
|||||||
"actix-remote-ip",
|
"actix-remote-ip",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"base64 0.21.2",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"clap",
|
"clap",
|
||||||
"diesel",
|
"diesel",
|
||||||
|
@ -36,3 +36,4 @@ httpdate = "1.0.2"
|
|||||||
zip = "0.6.6"
|
zip = "0.6.6"
|
||||||
mime_guess = "2.0.4"
|
mime_guess = "2.0.4"
|
||||||
tempfile = "3.7.1"
|
tempfile = "3.7.1"
|
||||||
|
base64 = "0.21.2"
|
@ -5,6 +5,7 @@ use crate::extractors::member_extractor::FamilyAndMemberInPath;
|
|||||||
use crate::models::{Member, MemberID, PhotoID, Sex};
|
use crate::models::{Member, MemberID, PhotoID, Sex};
|
||||||
use crate::services::{members_service, photos_service};
|
use crate::services::{members_service, photos_service};
|
||||||
use crate::utils::countries_utils;
|
use crate::utils::countries_utils;
|
||||||
|
use crate::utils::encode_utils::base64_enc;
|
||||||
use actix_multipart::form::tempfile::TempFile;
|
use actix_multipart::form::tempfile::TempFile;
|
||||||
use actix_multipart::form::MultipartForm;
|
use actix_multipart::form::MultipartForm;
|
||||||
use actix_web::{web, HttpResponse};
|
use actix_web::{web, HttpResponse};
|
||||||
@ -62,8 +63,8 @@ enum MemberControllerErr {
|
|||||||
MalformedBirthLastname,
|
MalformedBirthLastname,
|
||||||
#[error("Malformed email address!")]
|
#[error("Malformed email address!")]
|
||||||
MalformedEmailAddress,
|
MalformedEmailAddress,
|
||||||
#[error("Invalid email address!")]
|
#[error("Invalid email address (base64={0}) !")]
|
||||||
InvalidEmailAddress,
|
InvalidEmailAddress(String),
|
||||||
#[error("Malformed phone number!")]
|
#[error("Malformed phone number!")]
|
||||||
MalformedPhoneNumber,
|
MalformedPhoneNumber,
|
||||||
#[error("Malformed address!")]
|
#[error("Malformed address!")]
|
||||||
@ -132,7 +133,7 @@ impl MemberRequest {
|
|||||||
|
|
||||||
if let Some(mail) = &self.email {
|
if let Some(mail) = &self.email {
|
||||||
if !mailchecker::is_valid(mail) {
|
if !mailchecker::is_valid(mail) {
|
||||||
return Err(MemberControllerErr::InvalidEmailAddress.into());
|
return Err(MemberControllerErr::InvalidEmailAddress(base64_enc(mail)).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
geneit_backend/src/utils/encode_utils.rs
Normal file
6
geneit_backend/src/utils/encode_utils.rs
Normal 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)
|
||||||
|
}
|
@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
pub mod countries_utils;
|
pub mod countries_utils;
|
||||||
pub mod crypt_utils;
|
pub mod crypt_utils;
|
||||||
|
pub mod encode_utils;
|
||||||
pub mod string_utils;
|
pub mod string_utils;
|
||||||
pub mod time_utils;
|
pub mod time_utils;
|
||||||
|
Loading…
Reference in New Issue
Block a user