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:
		
							
								
								
									
										1
									
								
								geneit_backend/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								geneit_backend/Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -1295,6 +1295,7 @@ dependencies = [
 | 
			
		||||
 "actix-remote-ip",
 | 
			
		||||
 "actix-web",
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "base64 0.21.2",
 | 
			
		||||
 "bcrypt",
 | 
			
		||||
 "clap",
 | 
			
		||||
 "diesel",
 | 
			
		||||
 
 | 
			
		||||
@@ -35,4 +35,5 @@ uuid = { version = "1.4.1", features = ["v4"] }
 | 
			
		||||
httpdate = "1.0.2"
 | 
			
		||||
zip = "0.6.6"
 | 
			
		||||
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::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());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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 crypt_utils;
 | 
			
		||||
pub mod encode_utils;
 | 
			
		||||
pub mod string_utils;
 | 
			
		||||
pub mod time_utils;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user