diff --git a/src/callers/login.rs b/src/callers/login.rs index efa1144..fb065e5 100644 --- a/src/callers/login.rs +++ b/src/callers/login.rs @@ -154,7 +154,6 @@ pub mod endpoint { } } - // TODO: Add endpoint to get a refresh token pub async fn refresh_token( axum::Extension(pool): axum::Extension, axum::Json(payload): axum::Json, @@ -166,15 +165,10 @@ pub mod endpoint { let key = icarus_envy::environment::get_secret_key().await; if token_stuff::verify_token(&key, &payload.access_token) { - // * Check token type - // - For right now, just worry about service tokens - // * Create a new token with a longer expiration let token_type = token_stuff::get_token_type(&key, &payload.access_token).unwrap(); if token_stuff::is_token_type_valid(&token_type) { - // let (token_literal, dur) = token_stuff::create_service_refresh_token(&key, ) // Get passphrase record with id - // match repo::service::get_passphrase match token_stuff::extract_id_from_token(&key, &payload.access_token) { Ok(id) => match repo::service::get_passphrase(&pool, &id).await { Ok((returned_id, _, _)) => { diff --git a/src/main.rs b/src/main.rs index 1f5a4ba..e052521 100644 --- a/src/main.rs +++ b/src/main.rs @@ -465,38 +465,6 @@ mod tests { assert!(false, "Error: {err:?}"); } } - /* - let passphrase = - String::from("iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH"); - let payload = serde_json::json!({ - "passphrase": passphrase - }); - - match app - .oneshot( - Request::builder() - .method(axum::http::Method::POST) - .uri(callers::endpoints::SERVICE_LOGIN) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .body(Body::from(payload.to_string())) - .unwrap(), - ) - .await - { - Ok(response) => { - assert_eq!(StatusCode::OK, response.status(), "Status is not right"); - let body = axum::body::to_bytes(response.into_body(), usize::MAX) - .await - .unwrap(); - let parsed_body: callers::login::response::service_login::Response = - serde_json::from_slice(&body).unwrap(); - let _login_result = &parsed_body.data[0]; - } - Err(err) => { - assert!(false, "Error: {err:?}"); - } - } - */ let _ = db_mgr::drop_database(&tm_pool, &db_name).await; } diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 189ebbe..037ee0f 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -224,7 +224,6 @@ pub mod service { } } - // TODO: Write a function to get a passphrase record with an id pub async fn get_passphrase( pool: &sqlx::PgPool, id: &uuid::Uuid, diff --git a/src/token_stuff/mod.rs b/src/token_stuff/mod.rs index a0a1cba..64e4429 100644 --- a/src/token_stuff/mod.rs +++ b/src/token_stuff/mod.rs @@ -99,15 +99,7 @@ pub fn get_token_type(key: &String, token: &String) -> Result Err(std::io::Error::other(String::from("Invalid payload"))), // } - /* - match payload.claim("id") { - Some(id) => match uuid::Uuid::parse_str(id.as_str().unwrap()) { - Ok(extracted) => Ok(extracted), - Err(err) => Err(std::io::Error::other(err.to_string())), - }, - None => Err(std::io::Error::other("No claim found")), - */ + None => Err(std::io::Error::other(String::from("Invalid payload"))), }, Err(err) => Err(std::io::Error::other(err.to_string())), } @@ -115,7 +107,6 @@ pub fn get_token_type(key: &String, token: &String) -> Result bool { token_type == SERVICE_TOKEN_TYPE - // false } fn get_payload(