]> dev.renevier.net Git - syp.git/blobdiff - inc/html/install.php
do not allow empty passwords
[syp.git] / inc / html / install.php
index d3def31fe5b96dbb7273298cb98f7ac777e2e65c..4b2d02cb3673dca4cc1a1a53d096015f807cce6b 100644 (file)
       <link rel="stylesheet" href="./media/install.css" type="text/css" >
       <title><?php ptrans ('SYP wizard')?></title>
       <script type="text/javascript">
       <link rel="stylesheet" href="./media/install.css" type="text/css" >
       <title><?php ptrans ('SYP wizard')?></title>
       <script type="text/javascript">
+      var sypStrings = {
+            emptyPasswordError: "<?php ptrans('Password cannot be empty')?>"
+      };
+
       function init () {
         if (document.getElementById('db_host')) { 
             document.getElementById('db_host').focus();
       function init () {
         if (document.getElementById('db_host')) { 
             document.getElementById('db_host').focus();
             document.getElementById('admin_pass').select();
         }
       }
             document.getElementById('admin_pass').select();
         }
       }
+
+      function checkpwd () {
+          var pass = document.getElementById('admin_pass').value;
+          if (!pass) {
+              document.getElementById('empty_pass_error').innerHTML = sypStrings.emptyPasswordError;
+              document.getElementById('empty_pass_error').style.display = "block";
+              document.getElementById('admin_pass').focus();
+              return false;
+          }
+          return true;
+      }
       </script>
 </head>
 <body onload="init()">
       </script>
 </head>
 <body onload="init()">
     if ($users_table_exists) {
         par_success (trans ('Found user table.'));
     } else {
     if ($users_table_exists) {
         par_success (trans ('Found user table.'));
     } else {
-        if (isset($_POST ["admin_pass"])) {
+        $empty_pass = (isset ($_POST ["admin_pass"]) && (strlen ($_POST ["admin_pass"]) == 0));
+        if ($_POST ["admin_pass"]) {
             try {
                 $connection->create_users_table (true);
             } catch (Exception $e) {
             try {
                 $connection->create_users_table (true);
             } catch (Exception $e) {
             par_success (trans ('Admin password initialized.'));
 
         } else {
             par_success (trans ('Admin password initialized.'));
 
         } else {
-            print ('<form class="center" method="post" action="">
+            print ('<form class="center" method="post" action="" onsubmit="return checkpwd()">
                     <label for="admin_pass">' . trans ("choose admin password") . '</label>
                     <label for="admin_pass">' . trans ("choose admin password") . '</label>
-                    <input id="admin_pass" name="admin_pass" type="password">
-                    <input type="submit">
-                 </form>');
+                    <input id="admin_pass" name="admin_pass" type="password">');
+            if ($empty_pass) {
+                print ('<p class="error" id="empty_pass_error">' . trans('Password cannot be empty') . '</p>');
+            } else {
+                print ('<p class="error" style="display: none" id="empty_pass_error"></p>');
+            }
+            print ('<br><input type="submit"></form>');
             leave ();
         }
     }
             leave ();
         }
     }