Compare commits
3 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c13f99652 | ||
|
|
a948215538 | ||
|
|
13424fceeb |
@@ -85,7 +85,7 @@ pub fn diff_torrents(old: &[Torrent], new: &[Torrent]) -> DiffResult {
|
|||||||
has_changes = true;
|
has_changes = true;
|
||||||
|
|
||||||
// Log status changes for debugging
|
// Log status changes for debugging
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
"Torrent status changed: {} ({}) {:?} -> {:?}",
|
"Torrent status changed: {} ({}) {:?} -> {:?}",
|
||||||
new_t.name, new_t.hash, old_t.status, new_t.status
|
new_t.name, new_t.hash, old_t.status, new_t.status
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ pub async fn login_handler(
|
|||||||
let cookie = Cookie::build(("auth_token", token))
|
let cookie = Cookie::build(("auth_token", token))
|
||||||
.path("/")
|
.path("/")
|
||||||
.http_only(true)
|
.http_only(true)
|
||||||
.same_site(SameSite::Strict)
|
.same_site(SameSite::Lax)
|
||||||
.max_age(Duration::seconds(expires_in))
|
.max_age(Duration::seconds(expires_in))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
@@ -25,41 +25,61 @@ pub fn App() -> impl IntoView {
|
|||||||
// Check Auth & Setup Status on load
|
// Check Auth & Setup Status on load
|
||||||
create_effect(move |_| {
|
create_effect(move |_| {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
|
logging::log!("App initialization started...");
|
||||||
|
|
||||||
// 1. Check Setup Status
|
// 1. Check Setup Status
|
||||||
|
logging::log!("Checking setup status...");
|
||||||
let setup_res = gloo_net::http::Request::get("/api/setup/status").send().await;
|
let setup_res = gloo_net::http::Request::get("/api/setup/status").send().await;
|
||||||
if let Ok(resp) = setup_res {
|
|
||||||
if let Ok(status) = resp.json::<SetupStatus>().await {
|
match setup_res {
|
||||||
|
Ok(resp) => {
|
||||||
|
if resp.ok() {
|
||||||
|
match resp.json::<SetupStatus>().await {
|
||||||
|
Ok(status) => {
|
||||||
|
logging::log!("Setup status: completed={}", status.completed);
|
||||||
if !status.completed {
|
if !status.completed {
|
||||||
// Redirect to setup if not completed
|
logging::log!("Setup not completed, redirecting to /setup");
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
navigate("/setup", Default::default());
|
navigate("/setup", Default::default());
|
||||||
set_is_loading.set(false);
|
set_is_loading.set(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(e) => logging::error!("Failed to parse setup status: {}", e),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging::error!("Setup status request failed: {}", resp.status());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => logging::error!("Network error checking setup status: {}", e),
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Check Auth Status
|
// 2. Check Auth Status
|
||||||
|
logging::log!("Checking auth status...");
|
||||||
let auth_res = gloo_net::http::Request::get("/api/auth/check").send().await;
|
let auth_res = gloo_net::http::Request::get("/api/auth/check").send().await;
|
||||||
if let Ok(resp) = auth_res {
|
|
||||||
if resp.status() == 200 {
|
|
||||||
set_is_authenticated.set(true);
|
|
||||||
|
|
||||||
// Initialize push notifications logic only if authenticated
|
match auth_res {
|
||||||
// ... (Push notification logic moved here or kept global but guarded)
|
Ok(resp) => {
|
||||||
|
logging::log!("Auth check status: {}", resp.status());
|
||||||
|
if resp.status() == 200 {
|
||||||
|
logging::log!("Authenticated!");
|
||||||
|
set_is_authenticated.set(true);
|
||||||
} else {
|
} else {
|
||||||
|
logging::log!("Not authenticated, checking if redirect needed");
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
// If we are already on login or setup, don't redirect loop
|
|
||||||
let pathname = window().location().pathname().unwrap_or_default();
|
let pathname = window().location().pathname().unwrap_or_default();
|
||||||
if pathname != "/login" && pathname != "/setup" {
|
if pathname != "/login" && pathname != "/setup" {
|
||||||
navigate("/login", Default::default());
|
navigate("/login", Default::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(e) => logging::error!("Network error checking auth status: {}", e),
|
||||||
|
}
|
||||||
|
|
||||||
|
logging::log!("App initialization finished, disabling loader.");
|
||||||
set_is_loading.set(false);
|
set_is_loading.set(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize push notifications after user grants permission (Only if authenticated)
|
// Initialize push notifications after user grants permission (Only if authenticated)
|
||||||
create_effect(move |_| {
|
create_effect(move |_| {
|
||||||
if is_authenticated.get() {
|
if is_authenticated.get() {
|
||||||
|
|||||||
Reference in New Issue
Block a user