mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: use reference as constructor parameter
This commit is contained in:
parent
6499c8ce96
commit
02303d4b31
5 changed files with 9 additions and 9 deletions
|
|
@ -83,7 +83,7 @@ pub struct EncryptedApplicationDetails {
|
|||
|
||||
impl EncryptedApplicationDetails {
|
||||
pub async fn new(
|
||||
form: ApplicationDetails,
|
||||
form: &ApplicationDetails,
|
||||
recipients: Vec<&str>,
|
||||
) -> Result<EncryptedApplicationDetails, ServiceError> {
|
||||
let birthdate_str = form.birthdate.format(NAIVE_DATE_FMT).to_string();
|
||||
|
|
@ -116,7 +116,7 @@ impl EncryptedApplicationDetails {
|
|||
email: d.7,
|
||||
sex: d.8,
|
||||
personal_id_number: d.9,
|
||||
study: form.study,
|
||||
study: form.study.clone(),
|
||||
|
||||
parent_name: d.10,
|
||||
parent_surname: d.11,
|
||||
|
|
@ -296,7 +296,7 @@ pub mod tests {
|
|||
const PRIVATE_KEY: &str =
|
||||
"AGE-SECRET-KEY-14QG24502DMUUQDT2SPMX2YXPSES0X8UD6NT0PCTDAT6RH8V5Q3GQGSRXPS";
|
||||
let encrypted_details = EncryptedApplicationDetails::new(
|
||||
APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
&APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
vec![PUBLIC_KEY],
|
||||
)
|
||||
.await
|
||||
|
|
@ -329,7 +329,7 @@ pub mod tests {
|
|||
"AGE-SECRET-KEY-14QG24502DMUUQDT2SPMX2YXPSES0X8UD6NT0PCTDAT6RH8V5Q3GQGSRXPS";
|
||||
|
||||
let encrypted_details = EncryptedApplicationDetails::new(
|
||||
APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
&APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
vec![PUBLIC_KEY],
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
let encrypted_details: EncryptedApplicationDetails = EncryptedApplicationDetails::new(
|
||||
APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
&APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
vec!["age1u889gp407hsz309wn09kxx9anl6uns30m27lfwnctfyq9tq4qpus8tzmq5"],
|
||||
).await.unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ mod tests {
|
|||
let parent = Mutation::create_parent(&db, APPLICATION_ID).await.unwrap();
|
||||
|
||||
let encrypted_details: EncryptedApplicationDetails = EncryptedApplicationDetails::new(
|
||||
APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
&APPLICATION_DETAILS.lock().unwrap().clone(),
|
||||
vec!["age1u889gp407hsz309wn09kxx9anl6uns30m27lfwnctfyq9tq4qpus8tzmq5"],
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl ApplicationService {
|
|||
pub async fn add_all_details(
|
||||
db: &DbConn,
|
||||
application: i32,
|
||||
form: ApplicationDetails,
|
||||
form: &ApplicationDetails,
|
||||
) -> Result<(candidate::Model, parent::Model), ServiceError> {
|
||||
let candidate = Query::find_candidate_by_id(db, application)
|
||||
.await?
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ impl CandidateService {
|
|||
let enc_details_opt = EncryptedApplicationDetails::try_from((candidate, parent));
|
||||
if let Ok(enc_details) = enc_details_opt {
|
||||
let application_details = enc_details.decrypt(admin_private_key).await?;
|
||||
ApplicationService::add_all_details(db, id, application_details).await?;
|
||||
ApplicationService::add_all_details(db, id, &application_details).await?;
|
||||
}
|
||||
|
||||
Ok(new_password_plain)
|
||||
|
|
@ -382,7 +382,7 @@ pub mod tests {
|
|||
|
||||
let form = APPLICATION_DETAILS.lock().unwrap().clone();
|
||||
|
||||
ApplicationService::add_all_details(&db, candidate.application, form)
|
||||
ApplicationService::add_all_details(&db, candidate.application, &form)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue