17229: Webshell clear token from variable after logging in
[arvados-workbench2.git] / public / webshell / index.html
index 6fa6f313a965b82531dd2a9a6b280ac2d7d64d0c..3f25aed59b4447a9817f66d1fdd5a722211f19de 100644 (file)
         }
 
         var trySendToken = function() {
+          var token = urlParams.get('token');
+          if (token) {
+            history.replaceState(null, "", `/webshell/?host=${encodeURIComponent(urlParams.get('host'))}&login=${encodeURIComponent(urlParams.get('login'))}`)
+          } else if (localStorage.getItem('apiToken')) {
+            token = localStorage.getItem('apiToken');
+          } else {
+            // No token
+          }
           // change this text when PAM is reconfigured to present a
           // password prompt that we can wait for.
-          var token = urlParams.get('token');
           if (findText("assword:")) {
              sh.keysPressed(token + "\n");
              sh.vt100('(sent authentication token)\n');
+             token = null;
           } else {
             setTimeout(trySendToken, 200);
           }