mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Fix Backend version change detection
This commit is contained in:
parent
1e68d87d72
commit
f5eb03cb16
4 changed files with 111 additions and 33 deletions
108
Cargo.lock
generated
108
Cargo.lock
generated
|
@ -38,8 +38,8 @@ version = "0.1.74"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -301,8 +301,8 @@ version = "0.3.28"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -695,6 +695,7 @@ dependencies = [
|
|||
"jsonrpsee",
|
||||
"macaddr",
|
||||
"pwhash",
|
||||
"rbtag",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
|
@ -798,8 +799,8 @@ version = "1.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -834,8 +835,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 1.0.109",
|
||||
"version_check",
|
||||
]
|
||||
|
@ -846,11 +847,20 @@ version = "1.0.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "0.4.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
|
@ -875,13 +885,22 @@ dependencies = [
|
|||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"proc-macro2 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -914,6 +933,26 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rbtag"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72c64936fcc0b811890a9d90020f3df5cec9c604efde88af7db6a35d365132a3"
|
||||
dependencies = [
|
||||
"rbtag_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rbtag_derive"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b75511b710ccca8adbb211e04763bd8c78fed585b0ec188a20ed9b0dd95567c4"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
"syn 0.15.44",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
|
@ -1003,8 +1042,8 @@ version = "1.0.189"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -1142,14 +1181,25 @@ version = "2.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "0.15.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
|
@ -1159,8 +1209,8 @@ version = "2.0.38"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
|
@ -1185,8 +1235,8 @@ version = "1.0.50"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -1269,8 +1319,8 @@ version = "2.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -1381,8 +1431,8 @@ version = "0.1.27"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
|
@ -1454,6 +1504,12 @@ dependencies = [
|
|||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.4.1"
|
||||
|
@ -1499,8 +1555,8 @@ dependencies = [
|
|||
"if_chain",
|
||||
"lazy_static",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
"regex",
|
||||
"syn 1.0.109",
|
||||
"validator_types",
|
||||
|
@ -1512,7 +1568,7 @@ version = "0.15.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2ddf34293296847abfc1493b15c6e2f5d3cd19f57ad7d22673bf4c6278da329"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"proc-macro2 1.0.69",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ ipnet = { version = "2.8.0", features = ["serde"] }
|
|||
jsonrpsee = { version = "0.20.3", features = ["server"] }
|
||||
macaddr = { version = "1.0.1", features = ["serde"] }
|
||||
pwhash = "1.0.0"
|
||||
rbtag = "0.3.0"
|
||||
serde = { version = "1.0.189", features = ["derive"] }
|
||||
serde_json = "1.0.107"
|
||||
thiserror = "1.0.50"
|
||||
|
|
|
@ -58,12 +58,11 @@ export async function checkAuthentication() {
|
|||
try {
|
||||
const response = await pResponse;
|
||||
const last_hash = window.localStorage.getItem('commit_hash');
|
||||
|
||||
if (last_hash) {
|
||||
if (last_hash !== response.data.commit_hash) {
|
||||
console.log('Detected New Backend Version, Reloading...');
|
||||
console.log(`Detected New Backend Version ${response.data.commit_hash}, Reloading...`);
|
||||
window.localStorage.removeItem('commit_hash');
|
||||
// window.location.reload();
|
||||
window.location.reload();
|
||||
}
|
||||
} else window.localStorage.setItem('commit_hash', response.data.commit_hash);
|
||||
return {auth: 2, error: null};
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use rbtag::BuildInfo;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::super::AppState;
|
||||
use axum::routing::post;
|
||||
use axum::{Json, Router};
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tower_cookies::{Cookie, Cookies};
|
||||
|
||||
use axum::{
|
||||
|
@ -130,11 +131,32 @@ fn get_session(cookies: Cookies, state: SessionState) -> Result<Session, AuthErr
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(BuildInfo)]
|
||||
struct BuildTag;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct SessionResponse {
|
||||
pub commit_hash: String,
|
||||
}
|
||||
|
||||
async fn session_handler(cookies: Cookies, State(state): State<AppState>) -> impl IntoResponse {
|
||||
match get_session(cookies, state.session_state) {
|
||||
// TODO Return build git commit hash as json result for frontend reloading
|
||||
Ok(_) => return StatusCode::OK,
|
||||
Err(_) => return StatusCode::UNAUTHORIZED,
|
||||
Ok(_) => {
|
||||
return (
|
||||
StatusCode::OK,
|
||||
Json(SessionResponse {
|
||||
commit_hash: BuildTag {}.get_build_commit().to_string(),
|
||||
}),
|
||||
)
|
||||
}
|
||||
Err(_) => {
|
||||
return (
|
||||
StatusCode::UNAUTHORIZED,
|
||||
Json(SessionResponse {
|
||||
commit_hash: BuildTag {}.get_build_commit().to_string(),
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue