password.ejs 761 Bytes
<script type="text/javascript">
  post_data = {
    "collection":'<%= collection %>'
  }
    function winOpen() {
      var type = '<%= type %>';
      let sign = window.prompt("password");
  
      if (sign == type){
        redirectPost('/',post_data)
      }
      else{
        winOpen();
      }
    }

  function redirectPost(url, data) {
    var form = document.createElement('form');
    document.body.appendChild(form);
    form.method = 'post';
    form.action = url;
    for (var name in data) {
        var input = document.createElement('input');
        input.type = 'hidden';
        input.name = name;
        input.value = data[name];
        form.appendChild(input);
    }
    form.submit();
  }
  </script>

  <body onLoad="winOpen()"></body>