Add user status & fix get user
This commit is contained in:
parent
f5f35855ce
commit
81023f2042
722
Cargo.lock
generated
722
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "BitAuth"
|
name = "BitAuth"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -372,7 +372,7 @@ pub async fn get_user(pool: DBPool, login: String) -> Res<Users, SkyError> {
|
|||||||
let mut con = pool.get().await.unwrap();
|
let mut con = pool.get().await.unwrap();
|
||||||
|
|
||||||
let q = con
|
let q = con
|
||||||
.query_parse::<Users>(&query!("SELECT * FROM bitauth.users WHERE login = ?", login))
|
.query_parse::<Users>(&query!("SELECT * FROM bitauth.users_uuid WHERE login = ?", login))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(q?)
|
Ok(q?)
|
||||||
|
@ -7,6 +7,7 @@ pub const HEADER_HTML: &str = r#"
|
|||||||
<a href="/">index</a>
|
<a href="/">index</a>
|
||||||
<a href="/login">login</a>
|
<a href="/login">login</a>
|
||||||
<a href="/register">register</a>
|
<a href="/register">register</a>
|
||||||
|
<span>{USER_STATUS}</span>
|
||||||
<hr>
|
<hr>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
@ -16,7 +17,7 @@ pub const FOOTER_HTML: &str = r#"
|
|||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<hr>
|
<hr>
|
||||||
Page time: PAGE_TIMEµs.
|
Page time: {PAGE_TIME}µs.
|
||||||
Made by <a href="//bitheaven.ru/">BitHeaven</a>.
|
Made by <a href="//bitheaven.ru/">BitHeaven</a>.
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -67,13 +67,13 @@ type DBPool = Arc<Pool<ConnectionMgrTcp>>;
|
|||||||
type FullBytes = Result<Response<Full<Bytes>>>;
|
type FullBytes = Result<Response<Full<Bytes>>>;
|
||||||
|
|
||||||
|
|
||||||
const PORT: u16 = 8083;
|
const PORT: u16 = 8051;
|
||||||
|
|
||||||
const DB_POOL: u32 = 32;
|
const DB_POOL: u32 = 32;
|
||||||
const DB_ADDR: &str = "127.0.0.1";
|
const DB_ADDR: &str = "127.0.0.1";
|
||||||
const DB_PORT: u16 = 2003;
|
const DB_PORT: u16 = 2003;
|
||||||
const DB_USER: &str = "root";
|
const DB_USER: &str = "root";
|
||||||
const DB_PASS: &str = "5a14775a-a490-4212345678";
|
const DB_PASS: &str = "dBk6wUAynGRRLsSF";
|
||||||
|
|
||||||
const TOKEN_LIFETIME: u32 = 300;
|
const TOKEN_LIFETIME: u32 = 300;
|
||||||
const REFRESH_LIFETIME: u32 = 2_678_400;
|
const REFRESH_LIFETIME: u32 = 2_678_400;
|
||||||
@ -258,7 +258,14 @@ async fn handle_connection(req: Request<Incoming>, pool: DBPool, ip: String) ->
|
|||||||
headers.insert(hyper::header::CONTENT_TYPE, restype);
|
headers.insert(hyper::header::CONTENT_TYPE, restype);
|
||||||
parts.headers = headers;
|
parts.headers = headers;
|
||||||
|
|
||||||
let body = body.replace("PAGE_TIME", &format!("{}", time_mcs() - t));
|
if logged {
|
||||||
|
let body = body.replace("{USER_STATUS}", "AUTHORIZED");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let body = body.replace("{USER_STATUS}", "NOT AUTHORIZED");
|
||||||
|
}
|
||||||
|
|
||||||
|
let body = body.replace("{PAGE_TIME}", &format!("{}", time_mcs() - t));
|
||||||
Ok(Response::from_parts(parts, Full::new(Bytes::from(body))))
|
Ok(Response::from_parts(parts, Full::new(Bytes::from(body))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user