authorize: improved return messge
This commit is contained in:
parent
5d1b869124
commit
7d7617783f
1 changed files with 6 additions and 3 deletions
|
@ -101,15 +101,18 @@ fn authorize(username: &str, password: &str) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_user(headers: HeaderMap) -> StatusCode {
|
async fn auth_user(headers: HeaderMap) -> (StatusCode, Json<Value>) {
|
||||||
let username = headers["x-auth-user"].to_str().unwrap_or("");
|
let username = headers["x-auth-user"].to_str().unwrap_or("");
|
||||||
let password = headers["x-auth-key"].to_str().unwrap_or("");
|
let password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||||
|
|
||||||
if authorize(&username, &password) == false {
|
if authorize(&username, &password) == false {
|
||||||
return StatusCode::UNAUTHORIZED;
|
return (
|
||||||
|
StatusCode::UNAUTHORIZED,
|
||||||
|
Json(json!({"message" : "Unauthorized"})),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusCode::OK
|
(StatusCode::OK, Json(json!({"authorized" : "OK"})))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_progress(headers: HeaderMap, Json(payload): Json<UpdateProgress>) -> StatusCode {
|
async fn update_progress(headers: HeaderMap, Json(payload): Json<UpdateProgress>) -> StatusCode {
|
||||||
|
|
Loading…
Reference in a new issue