diff --git a/api/src/routes/admin.rs b/api/src/routes/admin.rs index 3700704..d7bfc0d 100644 --- a/api/src/routes/admin.rs +++ b/api/src/routes/admin.rs @@ -2,7 +2,7 @@ use std::net::{SocketAddr, IpAddr, Ipv4Addr}; use portfolio_core::{ crypto::random_8_char_string, - services::{admin_service::AdminService, candidate_service::CandidateService, application_service::ApplicationService, portfolio_service::PortfolioService}, responses::CandidateResponse, candidate_details::ApplicationDetails, sea_orm::prelude::Uuid, + services::{admin_service::AdminService, candidate_service::CandidateService, application_service::ApplicationService, portfolio_service::PortfolioService}, responses::BaseCandidateResponse, candidate_details::ApplicationDetails, sea_orm::prelude::Uuid, }; use requests::{AdminLoginRequest, RegisterRequest}; use rocket::http::{Cookie, Status, CookieJar}; @@ -11,7 +11,7 @@ use rocket::serde::json::Json; use sea_orm_rocket::Connection; -use crate::{guards::request::auth::AdminAuth, pool::Db, requests}; +use crate::{guards::request::{auth::AdminAuth, self}, pool::Db, requests}; #[post("/login", data = "")] pub async fn login( @@ -82,14 +82,14 @@ pub async fn hello(_session: AdminAuth) -> Result> { Ok("Hello admin".to_string()) } -#[post("/create", data = "")] +#[post("/create", data = "")] pub async fn create_candidate( conn: Connection<'_, Db>, _session: AdminAuth, - post_form: Json, + request: Json, ) -> Result> { let db = conn.into_inner(); - let form = post_form.into_inner(); + let form = request.into_inner(); let plain_text_password = random_8_char_string(); @@ -111,7 +111,7 @@ pub async fn list_candidates( session: AdminAuth, field: Option, page: Option, -) -> Result>, Custom> { +) -> Result>, Custom> { let db = conn.into_inner(); let private_key = session.get_private_key(); if let Some(field) = field.clone() { diff --git a/core/src/responses.rs b/core/src/responses.rs index c0b7e5b..970c7ba 100644 --- a/core/src/responses.rs +++ b/core/src/responses.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::{candidate_details::EncryptedString, error::ServiceError}; #[derive(Debug, Serialize)] -pub struct CandidateResponse { +pub struct BaseCandidateResponse { pub application_id: i32, pub name: String, pub surname: String, @@ -11,7 +11,7 @@ pub struct CandidateResponse { pub submitted: bool, } -impl CandidateResponse { +impl BaseCandidateResponse { pub async fn from_encrypted( private_key: &String, application_id: i32, diff --git a/core/src/services/candidate_service.rs b/core/src/services/candidate_service.rs index d127705..c750990 100644 --- a/core/src/services/candidate_service.rs +++ b/core/src/services/candidate_service.rs @@ -7,7 +7,7 @@ use crate::{ candidate_details::{EncryptedApplicationDetails}, crypto::{self, hash_password}, error::ServiceError, - Mutation, Query, responses::CandidateResponse, + Mutation, Query, responses::BaseCandidateResponse, }; use super::{session_service::{AdminUser, SessionService}, application_service::ApplicationService}; @@ -150,7 +150,7 @@ impl CandidateService { db: &DbConn, field_of_study: Option, page: Option, - ) -> Result, ServiceError> { + ) -> Result, ServiceError> { let candidates = Query::list_candidates( db, @@ -158,11 +158,11 @@ impl CandidateService { page ).await?; - let mut result: Vec = vec![]; + let mut result: Vec = vec![]; for candidate in candidates { result.push( - CandidateResponse::from_encrypted( + BaseCandidateResponse::from_encrypted( &private_key, candidate.application, candidate.name,