Maybe this time
Rust Build / Check (pull_request) Failing after 11s
Rust Build / Test Suite (pull_request) Successful in 53s
Rust Build / Rustfmt (pull_request) Successful in 1m21s
Rust Build / Clippy (pull_request) Successful in 1m46s
Rust Build / build (pull_request) Successful in 2m1s
Rust Build / Check (pull_request) Failing after 11s
Rust Build / Test Suite (pull_request) Successful in 53s
Rust Build / Rustfmt (pull_request) Successful in 1m21s
Rust Build / Clippy (pull_request) Successful in 1m46s
Rust Build / build (pull_request) Successful in 2m1s
This commit is contained in:
+14
-10
@@ -45,7 +45,8 @@ pub mod response {
|
||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct ServiceUserLoginResponse {
|
||||
pub message: String,
|
||||
pub data: Vec<textsender_models::user::ServiceUser>,
|
||||
// TODO: Change this to login result
|
||||
pub data: Vec<textsender_models::token::LoginResult>,
|
||||
}
|
||||
|
||||
pub async fn extract(
|
||||
@@ -208,7 +209,10 @@ pub async fn user_login(
|
||||
pub async fn service_user_login(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::Json(payload): axum::Json<request::ServiceUserLoginRequest>,
|
||||
) -> (axum::http::StatusCode, axum::Json<response::LoginResponse>) {
|
||||
) -> (
|
||||
axum::http::StatusCode,
|
||||
axum::Json<response::ServiceUserLoginResponse>,
|
||||
) {
|
||||
if payload.username.is_empty() || payload.passphrase.is_empty() {
|
||||
let reason = if payload.username.is_empty() {
|
||||
String::from("Username not provided")
|
||||
@@ -218,7 +222,7 @@ pub async fn service_user_login(
|
||||
|
||||
(
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: reason,
|
||||
data: Vec::new(),
|
||||
}),
|
||||
@@ -230,7 +234,7 @@ pub async fn service_user_login(
|
||||
println!("User does not exists");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: String::from("Unable to login"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
@@ -244,7 +248,7 @@ pub async fn service_user_login(
|
||||
eprintln!("Error: {err:?}");
|
||||
return (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: String::from("Unable to login"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
@@ -278,7 +282,7 @@ pub async fn service_user_login(
|
||||
|
||||
(
|
||||
axum::http::StatusCode::OK,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: String::from(
|
||||
super::messages::SUCCESSFUL_MESSAGE,
|
||||
),
|
||||
@@ -297,7 +301,7 @@ pub async fn service_user_login(
|
||||
eprintln!("Invalid token");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: String::from("Invalid attempt"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
@@ -307,7 +311,7 @@ pub async fn service_user_login(
|
||||
eprintln!("No match");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: String::from("Invalid attempt"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
@@ -316,7 +320,7 @@ pub async fn service_user_login(
|
||||
}
|
||||
Err(err) => (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: err.to_string(),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
@@ -326,7 +330,7 @@ pub async fn service_user_login(
|
||||
}
|
||||
Err(err) => (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
axum::Json(response::ServiceUserLoginResponse {
|
||||
message: err.to_string(),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user