mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-06 11:30:44 +00:00
fix: decrypt_all_details error code
This commit is contained in:
parent
1a23b764b5
commit
b097c531cc
3 changed files with 32 additions and 14 deletions
|
|
@ -167,6 +167,20 @@ impl EncryptedCandidateDetails {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_filled(&self) -> bool {
|
||||||
|
self.name.is_some() &&
|
||||||
|
self.surname.is_some() &&
|
||||||
|
self.birthplace.is_some() &&
|
||||||
|
self.birthdate.is_some() &&
|
||||||
|
self.address.is_some() &&
|
||||||
|
self.telephone.is_some() &&
|
||||||
|
self.citizenship.is_some() &&
|
||||||
|
self.email.is_some() &&
|
||||||
|
self.sex.is_some() &&
|
||||||
|
self.personal_id_number.is_some() &&
|
||||||
|
self.study.is_some()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl From<&candidate::Model> for EncryptedCandidateDetails {
|
impl From<&candidate::Model> for EncryptedCandidateDetails {
|
||||||
fn from(
|
fn from(
|
||||||
|
|
@ -226,6 +240,13 @@ impl EncryptedParentDetails {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_filled(&self) -> bool {
|
||||||
|
self.name.is_some() &&
|
||||||
|
self.surname.is_some() &&
|
||||||
|
self.telephone.is_some() &&
|
||||||
|
self.email.is_some()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl From<&parent::Model> for EncryptedParentDetails {
|
impl From<&parent::Model> for EncryptedParentDetails {
|
||||||
fn from(
|
fn from(
|
||||||
|
|
@ -272,6 +293,11 @@ impl EncryptedApplicationDetails {
|
||||||
parents: decrypted_parents,
|
parents: decrypted_parents,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_filled(&self) -> bool {
|
||||||
|
self.candidate.is_filled() &&
|
||||||
|
self.parents.iter().all(|p| p.is_filled())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(&candidate::Model, Vec<parent::Model>)> for EncryptedApplicationDetails {
|
impl From<(&candidate::Model, Vec<parent::Model>)> for EncryptedApplicationDetails {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,12 @@ impl ApplicationService {
|
||||||
let parents = Query::find_candidate_parents(db, &candidate).await?;
|
let parents = Query::find_candidate_parents(db, &candidate).await?;
|
||||||
let enc_details = EncryptedApplicationDetails::from((&candidate, parents));
|
let enc_details = EncryptedApplicationDetails::from((&candidate, parents));
|
||||||
|
|
||||||
enc_details.decrypt(private_key).await
|
if enc_details.is_filled() {
|
||||||
|
enc_details.decrypt(private_key).await
|
||||||
|
} else {
|
||||||
|
Err(ServiceError::Forbidden)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -167,19 +167,6 @@ impl CandidateService {
|
||||||
).await
|
).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_candidate_info(candidate: &candidate::Model) -> bool {
|
|
||||||
candidate.name.is_some()
|
|
||||||
&& candidate.surname.is_some()
|
|
||||||
&& candidate.birthplace.is_some()
|
|
||||||
&& candidate.birthdate.is_some()
|
|
||||||
&& candidate.address.is_some()
|
|
||||||
&& candidate.telephone.is_some()
|
|
||||||
&& candidate.citizenship.is_some()
|
|
||||||
&& candidate.email.is_some()
|
|
||||||
&& candidate.sex.is_some()
|
|
||||||
&& candidate.study.is_some()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn decrypt_private_key(
|
async fn decrypt_private_key(
|
||||||
candidate: candidate::Model,
|
candidate: candidate::Model,
|
||||||
password: String,
|
password: String,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue