mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-08 09:12:26 +00:00
feat: decrypt all parents details
This commit is contained in:
parent
617cddd698
commit
a453117e89
1 changed files with 14 additions and 9 deletions
|
|
@ -206,7 +206,7 @@ impl EncryptedParentDetails {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn decrypt(self, priv_key: String) -> Result<ParentDetails, ServiceError> {
|
pub async fn decrypt(&self, priv_key: String) -> Result<ParentDetails, ServiceError> {
|
||||||
let d = tokio::try_join!(
|
let d = tokio::try_join!(
|
||||||
self.name.decrypt(&priv_key),
|
self.name.decrypt(&priv_key),
|
||||||
self.surname.decrypt(&priv_key),
|
self.surname.decrypt(&priv_key),
|
||||||
|
|
@ -245,25 +245,30 @@ impl EncryptedApplicationDetails {
|
||||||
recipients: Vec<String>,
|
recipients: Vec<String>,
|
||||||
) -> Result<EncryptedApplicationDetails, ServiceError> {
|
) -> Result<EncryptedApplicationDetails, ServiceError> {
|
||||||
let candidate = EncryptedCandidateDetails::new(&form.candidate, recipients.clone()).await?;
|
let candidate = EncryptedCandidateDetails::new(&form.candidate, recipients.clone()).await?;
|
||||||
let parent = EncryptedParentDetails::new(&form.parents[0], recipients.clone()).await?; // TODO async
|
let mut enc_parents= vec![];
|
||||||
|
for parent in form.parents.iter() {
|
||||||
|
enc_parents.push(
|
||||||
|
EncryptedParentDetails::new(parent, recipients.clone()).await?
|
||||||
|
);
|
||||||
|
}
|
||||||
Ok(
|
Ok(
|
||||||
EncryptedApplicationDetails {
|
EncryptedApplicationDetails {
|
||||||
candidate,
|
candidate,
|
||||||
parents: vec![parent],
|
parents: enc_parents,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn decrypt(self, priv_key: String) -> Result<ApplicationDetails, ServiceError> {
|
pub async fn decrypt(self, priv_key: String) -> Result<ApplicationDetails, ServiceError> {
|
||||||
/* let (candidate, parent) = tokio::try_join!(
|
|
||||||
&self.candidate.decrypt(priv_key.clone()),
|
|
||||||
self.parents[0].decrypt(priv_key),
|
|
||||||
)?; */
|
|
||||||
let candidate = self.candidate.decrypt(priv_key.clone()).await?;
|
let candidate = self.candidate.decrypt(priv_key.clone()).await?;
|
||||||
let parent = self.parents[0].clone().decrypt(priv_key).await?;
|
let mut parents = vec![];
|
||||||
|
for parent in self.parents.iter() {
|
||||||
|
let dec = parent.decrypt(priv_key.clone()).await?;
|
||||||
|
parents.push(dec);
|
||||||
|
}
|
||||||
Ok(ApplicationDetails {
|
Ok(ApplicationDetails {
|
||||||
candidate,
|
candidate,
|
||||||
parents: vec![parent],
|
parents: parents,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue