mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-05 11:00:56 +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();
|
let db = conn.into_inner();
|
||||||
println!("{} {}", login_form.application_id, login_form.password);
|
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.application_id,
|
||||||
login_form.password.to_string()
|
login_form.password.to_string()
|
||||||
).await;
|
).await;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ impl CandidateService {
|
||||||
Ok(jwt)
|
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 {
|
let candidate = match Query::find_candidate_by_id(db, user_id).await {
|
||||||
Ok(candidate) => match candidate {
|
Ok(candidate) => match candidate {
|
||||||
Some(candidate) => candidate,
|
Some(candidate) => candidate,
|
||||||
|
|
@ -174,7 +174,7 @@ mod tests {
|
||||||
Mutation::create_candidate(&db, form, &"Tajny_kod".to_string()).await.unwrap();
|
Mutation::create_candidate(&db, form, &"Tajny_kod".to_string()).await.unwrap();
|
||||||
|
|
||||||
// correct password
|
// correct password
|
||||||
let session = CandidateService::get_session(
|
let session = CandidateService::new_session(
|
||||||
db,
|
db,
|
||||||
5555555,
|
5555555,
|
||||||
"Tajny_kod".to_string()
|
"Tajny_kod".to_string()
|
||||||
|
|
@ -201,7 +201,7 @@ mod tests {
|
||||||
|
|
||||||
// incorrect password
|
// incorrect password
|
||||||
assert!(
|
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