Implement needed handlers to get to the initial download

`/api/start`
`/api/dummy/login`
`/apt/user`
`/api/purchase`
This commit is contained in:
Ethan O'Brien
2024-02-23 13:28:44 -06:00
parent f48ae94c0e
commit 9ce5f9bd42
12 changed files with 740 additions and 1 deletions

24
src/router/login.rs Normal file
View File

@ -0,0 +1,24 @@
use json;
use json::object;
use crate::router::global;
//use crate::encryption;
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue};
use crate::router::userdata;
//First time login handler
pub fn dummy(req: HttpRequest, _body: String) -> HttpResponse {
//let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
let blank_header = HeaderValue::from_static("");
let key = req.headers().get("a6573cbe").unwrap_or(&blank_header).to_str().unwrap_or("");
let user = userdata::get_acc(key, "");
println!("new uid: {}", user["user"]["id"].clone());
let resp = object!{
"code": 0,
"server_time": global::timestamp(),
"data": {
"user_id": user["user"]["id"].clone()
}
};
global::send(resp)
}