Răsfoiți Sursa

Fix decision on whether to display admin page

Lee Morgan 4 săptămâni în urmă
părinte
comite
620fbaef2a
2 a modificat fișierele cu 4 adăugiri și 4 ștergeri
  1. 2 2
      src/controllers/home.rs
  2. 2 2
      ui/index.js

+ 2 - 2
src/controllers/home.rs

@@ -8,8 +8,8 @@ const HTML: &str = include_str!("../../ui/build.html");
 pub async fn route(users: web::Data<Mutex<Vec<User>>>) -> HttpResponse {
     if users.lock().unwrap().is_empty() {
         let updated_html = HTML.replacen(
-            "window.adminExists = true;",
-            "window.adminExists = false;",
+            "window.adminExists=\"true\";",
+            "window.adminExists=\"false\";",
             1
         );
         HttpResponse::Ok().body(updated_html)

+ 2 - 2
ui/index.js

@@ -2,7 +2,7 @@ import loginPage from "./login/index.js";
 import dashboardPage from "./dashboard/index.js";
 import adminCreatePage from "./adminCreate/index.js";
 
-window.adminExists = true;
+window.adminExists = "true";
 
 let pages = document.querySelectorAll(".page");
 
@@ -22,7 +22,7 @@ let openPage = (page)=>{
 }
 
 //Check for login
-if(!window.adminExists){
+if(window.adminExists !== "true"){
     adminCreatePage.display();
 }else if(localStorage.getItem("loggedIn") === "true"){
     dashboardPage.display();