refix
This commit is contained in:
parent
41ece3063c
commit
2e8d3d2701
1 changed files with 6 additions and 3 deletions
|
@ -36,7 +36,7 @@ async fn root() -> &'static str {
|
||||||
"KOreader sync server"
|
"KOreader sync server"
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_user(Json(payload): Json<User>) -> StatusCode {
|
async fn create_user(Json(payload): Json<User>) -> (StatusCode, String) {
|
||||||
let client = redis::Client::open("redis://127.0.0.1/").unwrap();
|
let client = redis::Client::open("redis://127.0.0.1/").unwrap();
|
||||||
let mut con = client.get_connection().unwrap();
|
let mut con = client.get_connection().unwrap();
|
||||||
|
|
||||||
|
@ -50,10 +50,13 @@ async fn create_user(Json(payload): Json<User>) -> StatusCode {
|
||||||
if does_exist == false {
|
if does_exist == false {
|
||||||
let _: () = con.set(&user_key, password).unwrap();
|
let _: () = con.set(&user_key, password).unwrap();
|
||||||
} else {
|
} else {
|
||||||
return StatusCode::PAYMENT_REQUIRED;
|
return (
|
||||||
|
StatusCode::PAYMENT_REQUIRED,
|
||||||
|
"Username is already registered.".to_owned(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusCode::CREATED
|
(StatusCode::CREATED, format!("username = {username}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn auth_user(headers: HeaderMap) -> StatusCode {
|
async fn auth_user(headers: HeaderMap) -> StatusCode {
|
||||||
|
|
Loading…
Reference in a new issue