mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: decrypt portfolio
This commit is contained in:
parent
6d386e90a4
commit
c352dc0212
1 changed files with 20 additions and 0 deletions
|
|
@ -218,6 +218,26 @@ impl CandidateService {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_portfolio(candidate_id: i32, db: &DbConn) -> Result<Vec<u8>, ServiceError> {
|
||||
let Ok(candidate) = Query::find_candidate_by_id(db, candidate_id).await else {
|
||||
return Err(ServiceError::DbError);
|
||||
};
|
||||
|
||||
let Some(candidate) = candidate else {
|
||||
return Err(ServiceError::UserNotFound);
|
||||
};
|
||||
|
||||
let candidate_public_key = candidate.public_key;
|
||||
|
||||
let path = Path::new(&candidate_id.to_string()).join("PORTFOLIO.zip");
|
||||
|
||||
let Ok(buffer) = crypto::decrypt_file_with_private_key_as_buffer(path, &candidate_public_key).await else {
|
||||
return Err(ServiceError::CryptoDecryptFailed);
|
||||
};
|
||||
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
async fn decrypt_private_key(
|
||||
candidate: candidate::Model,
|
||||
password: String,
|
||||
|
|
|
|||
Loading…
Reference in a new issue