tsk-69: Login change

This commit is contained in:
2025-10-22 11:13:35 -04:00
parent b4fbf252c7
commit 99bd43fb8c

View File

@@ -118,7 +118,7 @@ pub mod endpoint {
}),
)
} else {
return not_found("Could not verify password").await;
return not_found("Could not verify token").await;
}
} else {
return not_found("Error Hashing").await;
@@ -154,7 +154,7 @@ pub mod endpoint {
let mut response = response::service_login::Response::default();
match repo::service::valid_passphrase(&pool, &payload.passphrase).await {
Ok((id, _passphrase, _date_created)) => {
Ok((id, username, _date_created)) => {
let key = icarus_envy::environment::get_secret_key().await.value;
let (token_literal, duration) =
token_stuff::create_service_token(&key, &id).unwrap();
@@ -162,7 +162,7 @@ pub mod endpoint {
if token_stuff::verify_token(&key, &token_literal) {
let login_result = icarus_models::login_result::LoginResult {
id,
username: String::from(SERVICE_USERNAME),
username,
token: token_literal,
token_type: String::from(icarus_models::token::TOKEN_TYPE),
expiration: duration,
@@ -216,15 +216,15 @@ pub mod endpoint {
// Get passphrase record with id
match token_stuff::extract_id_from_token(&key, &payload.access_token) {
Ok(id) => match repo::service::get_passphrase(&pool, &id).await {
Ok((returned_id, _, _)) => {
match token_stuff::create_service_refresh_token(&key, &returned_id) {
Ok((username, _, _)) => {
match token_stuff::create_service_refresh_token(&key, &id) {
Ok((access_token, exp_dur)) => {
let login_result = icarus_models::login_result::LoginResult {
id: returned_id,
id,
token: access_token,
expiration: exp_dur,
token_type: String::from(icarus_models::token::TOKEN_TYPE),
username: String::from(SERVICE_USERNAME),
username,
};
response.message = String::from("Successful");
response.data.push(login_result);