OSDN Git Service

fixed caching errors
authorJohn-Anthony Elenis <johnanthonyelenis@gmail.com>
Sat, 24 Aug 2019 18:07:37 +0000 (14:07 -0400)
committerJohn-Anthony Elenis <johnanthonyelenis@gmail.com>
Sat, 24 Aug 2019 18:07:37 +0000 (14:07 -0400)
index.html
js/LoginManager.js
js/theme.js

index f40d79c..9963f65 100644 (file)
@@ -11,6 +11,7 @@
 <script src="js/jquery-ui.min.js"></script>
 <script src="js/materialize.min.js"></script>
 
+
 <!-- Sample lightdm object (for browser use only) -->
 <!-- <script src="js/lightdm-sample.js"></script> -->
 
     /* Use custom logging for debugging without a browser.
        Pass true to show logger output on screen */
     const log = new Logger(false);
+
     /* Define this fuction so lightdm doesn't crash, gets redefined
     in login manager. */
     window.authentication_complete = function() {};
index d48111e..d09d76d 100644 (file)
@@ -20,6 +20,7 @@ class LoginManager {
 
                        // begin intializing once the DOM has finished loading
                        $(document).ready(() => {
+
                                /* read config file, use defaults on failure, since config is in JSON
                                reading mut be async */
                                $.getJSON("json/LoginManager.json", (data) => {
@@ -106,6 +107,10 @@ class LoginManager {
                                this.lightdm.respond(password);
                        }
                        let auth_complete_cb = () => { // called as a result of respond
+        try { // attempt to cache selcted username
+          localStorage.setItem("user", username);
+        } catch(e) {};
+
                                if (typeof callback == "function")
                                    callback(this.lightdm.is_authenticated);
 
@@ -140,15 +145,14 @@ class LoginManager {
                                log.error("Attempting to login without authentication.");
                                return;
                        }
-
+      log.normal(`storing:: ${session_key}`);
 
       // store selected options in the cache
       try {
-        localStorage.setItem("user", username);
         localStorage.setItem("session", session_key);
-      } catch(e) {}
+      } catch(e) {};
 
-                       this.lightdm.start_session_sync(session_key);
+      this.lightdm.start_session_sync(session_key);
                }
 
                /**
@@ -192,7 +196,8 @@ class LoginManager {
        try  {
          let prev = localStorage.getItem("session");
          // make sure the stored session is valid
-         let session = this.lightdm.sessions.find((x) => x.name == prev)
+         let session = this.lightdm.sessions.find((x) => x.name == prev);
+
          if (session)
             $el.val(session.name);
        } catch (e) {}
index 7735f7d..ea3bf8f 100644 (file)
@@ -24,7 +24,7 @@ $(greeter).on("ready", function(e) {
        greeter.fillUserSelect($user);
        greeter.fillSessionSelect($session);
 
-
+       
 
        /* Bind shutdown, restart hibernate and suspend to the
        appropriate buttons */