This commit is contained in:
		@@ -34,18 +34,16 @@ impl AccommodationRequest {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        accommodation.name = self.name;
 | 
					        accommodation.name = self.name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(d) = &self.description {
 | 
					        if let Some(d) = &self.description
 | 
				
			||||||
            if !c.accommodation_description_len.validate(d) {
 | 
					            && !c.accommodation_description_len.validate(d) {
 | 
				
			||||||
                return Err(AccommodationListControllerErr::InvalidDescriptionLength.into());
 | 
					                return Err(AccommodationListControllerErr::InvalidDescriptionLength.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        accommodation.description.clone_from(&self.description);
 | 
					        accommodation.description.clone_from(&self.description);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(c) = &self.color {
 | 
					        if let Some(c) = &self.color
 | 
				
			||||||
            if !lazy_regex::regex!("[a-fA-F0-9]{6}").is_match(c) {
 | 
					            && !lazy_regex::regex!("[a-fA-F0-9]{6}").is_match(c) {
 | 
				
			||||||
                return Err(AccommodationListControllerErr::MalformedColor.into());
 | 
					                return Err(AccommodationListControllerErr::MalformedColor.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        accommodation.color.clone_from(&self.color);
 | 
					        accommodation.color.clone_from(&self.color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        accommodation.need_validation = self.need_validation;
 | 
					        accommodation.need_validation = self.need_validation;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,23 +48,20 @@ impl CoupleRequest {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(husband) = self.husband {
 | 
					        if let Some(husband) = self.husband
 | 
				
			||||||
            if !members_service::exists(couple.family_id(), husband).await? {
 | 
					            && !members_service::exists(couple.family_id(), husband).await? {
 | 
				
			||||||
                return Err(CoupleControllerErr::HusbandNotExisting.into());
 | 
					                return Err(CoupleControllerErr::HusbandNotExisting.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(d) = &self.wedding {
 | 
					        if let Some(d) = &self.wedding
 | 
				
			||||||
            if !d.check() {
 | 
					            && !d.check() {
 | 
				
			||||||
                return Err(CoupleControllerErr::MalformedDateOfWedding.into());
 | 
					                return Err(CoupleControllerErr::MalformedDateOfWedding.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(d) = &self.divorce {
 | 
					        if let Some(d) = &self.divorce
 | 
				
			||||||
            if !d.check() {
 | 
					            && !d.check() {
 | 
				
			||||||
                return Err(CoupleControllerErr::MalformedDateOfDivorce.into());
 | 
					                return Err(CoupleControllerErr::MalformedDateOfDivorce.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        couple.set_wife(self.wife);
 | 
					        couple.set_wife(self.wife);
 | 
				
			||||||
        couple.set_husband(self.husband);
 | 
					        couple.set_husband(self.husband);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,11 +95,10 @@ fn check_opt_str_val(
 | 
				
			|||||||
    c: SizeConstraint,
 | 
					    c: SizeConstraint,
 | 
				
			||||||
    err: MemberControllerErr,
 | 
					    err: MemberControllerErr,
 | 
				
			||||||
) -> anyhow::Result<()> {
 | 
					) -> anyhow::Result<()> {
 | 
				
			||||||
    if let Some(v) = val {
 | 
					    if let Some(v) = val
 | 
				
			||||||
        if !c.validate(v) {
 | 
					        && !c.validate(v) {
 | 
				
			||||||
            return Err(err.into());
 | 
					            return Err(err.into());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    Ok(())
 | 
					    Ok(())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -151,11 +150,10 @@ impl MemberRequest {
 | 
				
			|||||||
            MemberControllerErr::MalformedEmailAddress,
 | 
					            MemberControllerErr::MalformedEmailAddress,
 | 
				
			||||||
        )?;
 | 
					        )?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(mail) = &self.email {
 | 
					        if let Some(mail) = &self.email
 | 
				
			||||||
            if !mailchecker::is_valid(mail) {
 | 
					            && !mailchecker::is_valid(mail) {
 | 
				
			||||||
                return Err(MemberControllerErr::InvalidEmailAddress.into());
 | 
					                return Err(MemberControllerErr::InvalidEmailAddress.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        check_opt_str_val(
 | 
					        check_opt_str_val(
 | 
				
			||||||
            &self.phone,
 | 
					            &self.phone,
 | 
				
			||||||
@@ -187,23 +185,20 @@ impl MemberRequest {
 | 
				
			|||||||
            MemberControllerErr::MalformedCountry,
 | 
					            MemberControllerErr::MalformedCountry,
 | 
				
			||||||
        )?;
 | 
					        )?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(c) = &self.country {
 | 
					        if let Some(c) = &self.country
 | 
				
			||||||
            if !countries_utils::is_code_valid(c) {
 | 
					            && !countries_utils::is_code_valid(c) {
 | 
				
			||||||
                return Err(MemberControllerErr::InvalidCountryCode.into());
 | 
					                return Err(MemberControllerErr::InvalidCountryCode.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(d) = &self.birth {
 | 
					        if let Some(d) = &self.birth
 | 
				
			||||||
            if !d.check() {
 | 
					            && !d.check() {
 | 
				
			||||||
                return Err(MemberControllerErr::MalformedDateOfBirth.into());
 | 
					                return Err(MemberControllerErr::MalformedDateOfBirth.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(d) = &self.death {
 | 
					        if let Some(d) = &self.death
 | 
				
			||||||
            if !d.check() {
 | 
					            && !d.check() {
 | 
				
			||||||
                return Err(MemberControllerErr::MalformedDateOfDeath.into());
 | 
					                return Err(MemberControllerErr::MalformedDateOfDeath.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        check_opt_str_val(
 | 
					        check_opt_str_val(
 | 
				
			||||||
            &self.note,
 | 
					            &self.note,
 | 
				
			||||||
@@ -221,11 +216,10 @@ impl MemberRequest {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(father) = self.father {
 | 
					        if let Some(father) = self.father
 | 
				
			||||||
            if !members_service::exists(member.family_id(), father).await? {
 | 
					            && !members_service::exists(member.family_id(), father).await? {
 | 
				
			||||||
                return Err(MemberControllerErr::FatherNotExisting.into());
 | 
					                return Err(MemberControllerErr::FatherNotExisting.into());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        member.first_name = self.first_name;
 | 
					        member.first_name = self.first_name;
 | 
				
			||||||
        member.last_name = self.last_name;
 | 
					        member.last_name = self.last_name;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,16 +36,15 @@ async fn get_photo(id: &PhotoIdPath, full_size: bool, req: HttpRequest) -> HttpR
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check if an upload is un-necessary
 | 
					    // Check if an upload is un-necessary
 | 
				
			||||||
    if let Some(c) = req.headers().get(header::IF_NONE_MATCH) {
 | 
					    if let Some(c) = req.headers().get(header::IF_NONE_MATCH)
 | 
				
			||||||
        if c.to_str().unwrap_or("") == hash {
 | 
					        && c.to_str().unwrap_or("") == hash {
 | 
				
			||||||
            return Ok(HttpResponse::NotModified().finish());
 | 
					            return Ok(HttpResponse::NotModified().finish());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) {
 | 
					    if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) {
 | 
				
			||||||
        let date_str = c.to_str().unwrap_or("");
 | 
					        let date_str = c.to_str().unwrap_or("");
 | 
				
			||||||
        if let Ok(date) = httpdate::parse_http_date(date_str) {
 | 
					        if let Ok(date) = httpdate::parse_http_date(date_str)
 | 
				
			||||||
            if date
 | 
					            && date
 | 
				
			||||||
                .add(Duration::from_secs(1))
 | 
					                .add(Duration::from_secs(1))
 | 
				
			||||||
                .duration_since(UNIX_EPOCH)
 | 
					                .duration_since(UNIX_EPOCH)
 | 
				
			||||||
                .unwrap()
 | 
					                .unwrap()
 | 
				
			||||||
@@ -54,7 +53,6 @@ async fn get_photo(id: &PhotoIdPath, full_size: bool, req: HttpRequest) -> HttpR
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                return Ok(HttpResponse::NotModified().finish());
 | 
					                return Ok(HttpResponse::NotModified().finish());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let bytes = s3_connection::get_file(&match full_size {
 | 
					    let bytes = s3_connection::get_file(&match full_size {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -149,11 +149,10 @@ pub mod loop_detection {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    impl LoopStack<'_> {
 | 
					    impl LoopStack<'_> {
 | 
				
			||||||
        pub fn contains(&self, id: MemberID) -> bool {
 | 
					        pub fn contains(&self, id: MemberID) -> bool {
 | 
				
			||||||
            if let Some(ls) = &self.prev {
 | 
					            if let Some(ls) = &self.prev
 | 
				
			||||||
                if ls.contains(id) {
 | 
					                && ls.contains(id) {
 | 
				
			||||||
                    return true;
 | 
					                    return true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            self.curr == id
 | 
					            self.curr == id
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -64,7 +64,7 @@ fn redis_key(state: &str) -> String {
 | 
				
			|||||||
    format!("oidc-state-{state}")
 | 
					    format!("oidc-state-{state}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async fn load_provider_info(prov_id: &str) -> anyhow::Result<OpenIDClient> {
 | 
					async fn load_provider_info(prov_id: &str) -> anyhow::Result<OpenIDClient<'_>> {
 | 
				
			||||||
    let prov = AppConfig::get()
 | 
					    let prov = AppConfig::get()
 | 
				
			||||||
        .openid_providers()
 | 
					        .openid_providers()
 | 
				
			||||||
        .into_iter()
 | 
					        .into_iter()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user