Working login page and user auth configuration

This commit is contained in:
Michael Jumper
2010-12-04 20:47:34 -08:00
parent a8d9d4f256
commit ff9e1664a6
10 changed files with 362 additions and 39 deletions

View File

@@ -40,6 +40,9 @@
<div id="login-dialog">
<h1>Guacamole Login</h1>
<p id="login-error"></p>
<form id="login-form" action="#">
<table id="login-fields">
<tr>
@@ -124,10 +127,33 @@
loginForm.onsubmit = function() {
// FIXME: Do ACTUAL login here
var username = document.getElementById("username");
var password = document.getElementById("password");
loginUI.style.display = "none";
startGuacamole();
var data =
"username=" + encodeURIComponent(username.value)
+ "&password=" + encodeURIComponent(password.value)
var xmlhttprequest = new XMLHttpRequest();
xmlhttprequest.open("POST", "login", false);
xmlhttprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttprequest.setRequestHeader("Content-length", data.length);
xmlhttprequest.send(data);
if (xmlhttprequest.status == 200) {
loginUI.style.display = "none";
startGuacamole();
}
else {
var loginError = document.getElementById("login-error");
// Display error, reset and refocus password field
loginError.textContent = "Invalid login. Please try again.";
password.value = "";
password.focus();
}
return false;