Fix compilation errors: Resolve utoipa derive issues, add time dependency, and correct Axum middleware signature
Some checks failed
Build MIPS Binary / build (push) Has been cancelled
Some checks failed
Build MIPS Binary / build (push) Has been cancelled
This commit is contained in:
@@ -15,7 +15,7 @@ pub struct LoginRequest {
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct UserResponse {
|
||||
username: String,
|
||||
}
|
||||
@@ -76,6 +76,13 @@ pub async fn login_handler(
|
||||
}
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/auth/logout",
|
||||
responses(
|
||||
(status = 200, description = "Logged out")
|
||||
)
|
||||
)]
|
||||
pub async fn logout_handler(
|
||||
State(state): State<AppState>,
|
||||
jar: CookieJar,
|
||||
@@ -93,6 +100,14 @@ pub async fn logout_handler(
|
||||
(StatusCode::OK, jar.add(cookie), "Logged out").into_response()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/auth/check",
|
||||
responses(
|
||||
(status = 200, description = "Authenticated"),
|
||||
(status = 401, description = "Not authenticated")
|
||||
)
|
||||
)]
|
||||
pub async fn check_auth_handler(
|
||||
State(state): State<AppState>,
|
||||
jar: CookieJar,
|
||||
|
||||
@@ -13,7 +13,7 @@ pub struct SetupRequest {
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct SetupStatusResponse {
|
||||
completed: bool,
|
||||
}
|
||||
|
||||
@@ -12,9 +12,8 @@ use axum::{
|
||||
routing::{get, post},
|
||||
Router,
|
||||
middleware::{self, Next},
|
||||
extract::Request,
|
||||
response::Response,
|
||||
http::StatusCode,
|
||||
http::{StatusCode, Request},
|
||||
body::Body,
|
||||
};
|
||||
use axum_extra::extract::cookie::CookieJar;
|
||||
@@ -47,7 +46,7 @@ pub struct AppState {
|
||||
async fn auth_middleware(
|
||||
state: axum::extract::State<AppState>,
|
||||
jar: CookieJar,
|
||||
request: Request<Body>,
|
||||
request: Request,
|
||||
next: Next,
|
||||
) -> Result<Response, StatusCode> {
|
||||
// Skip auth for public paths
|
||||
@@ -72,7 +71,6 @@ async fn auth_middleware(
|
||||
|
||||
Err(StatusCode::UNAUTHORIZED)
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
|
||||
Reference in New Issue
Block a user