mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-17 21:41:20 +00:00
refactor: rename get_session to new_session
This commit is contained in:
parent
fa74688ca3
commit
59e028b0ed
2 changed files with 4 additions and 4 deletions
|
|
@ -74,7 +74,7 @@ async fn login(conn: Connection<'_, Db>, login_form: Json<LoginRequest>) -> Resu
|
|||
let db = conn.into_inner();
|
||||
println!("{} {}", login_form.application_id, login_form.password);
|
||||
|
||||
let session_token = CandidateService::get_session(db,
|
||||
let session_token = CandidateService::new_session(db,
|
||||
login_form.application_id,
|
||||
login_form.password.to_string()
|
||||
).await;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ impl CandidateService {
|
|||
Ok(jwt)
|
||||
}
|
||||
|
||||
pub async fn get_session(db: &DatabaseConnection, user_id: i32, password: String) -> Result<String, ServiceError> {
|
||||
pub async fn new_session(db: &DatabaseConnection, user_id: i32, password: String) -> Result<String, ServiceError> {
|
||||
let candidate = match Query::find_candidate_by_id(db, user_id).await {
|
||||
Ok(candidate) => match candidate {
|
||||
Some(candidate) => candidate,
|
||||
|
|
@ -174,7 +174,7 @@ mod tests {
|
|||
Mutation::create_candidate(&db, form, &"Tajny_kod".to_string()).await.unwrap();
|
||||
|
||||
// correct password
|
||||
let session = CandidateService::get_session(
|
||||
let session = CandidateService::new_session(
|
||||
db,
|
||||
5555555,
|
||||
"Tajny_kod".to_string()
|
||||
|
|
@ -201,7 +201,7 @@ mod tests {
|
|||
|
||||
// incorrect password
|
||||
assert!(
|
||||
CandidateService::get_session(db, candidate_form.application, "Spatny_kod".to_string()).await.is_err()
|
||||
CandidateService::new_session(db, candidate_form.application, "Spatny_kod".to_string()).await.is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue