This commit is contained in:
Martin Brodbeck 2023-09-26 20:56:44 +02:00
parent 0848e5bd5d
commit 2fd01b6e9f

View file

@ -59,7 +59,7 @@ async fn root() -> &'static str {
"KOreader sync server" "KOreader sync server"
} }
async fn create_user(Json(payload): Json<User>) -> (StatusCode, String) { async fn create_user(Json(payload): Json<User>) -> (StatusCode, Json<Value>) {
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();
@ -75,11 +75,11 @@ async fn create_user(Json(payload): Json<User>) -> (StatusCode, String) {
} else { } else {
return ( return (
StatusCode::PAYMENT_REQUIRED, StatusCode::PAYMENT_REQUIRED,
"Username is already registered.".to_owned(), Json(json!({ "message" : "Username is already registered." })),
); );
} }
(StatusCode::CREATED, format!("username = {username}")) (StatusCode::CREATED, Json(json!({ "username" : username })))
} }
fn authorize(username: &str, password: &str) -> bool { fn authorize(username: &str, password: &str) -> bool {