diff --git a/guacamole/src/main/webapp/scripts/root-ui.js b/guacamole/src/main/webapp/scripts/root-ui.js index 4de3d357a..5c8091958 100644 --- a/guacamole/src/main/webapp/scripts/root-ui.js +++ b/guacamole/src/main/webapp/scripts/root-ui.js @@ -140,36 +140,6 @@ GuacamoleRootUI.RecentConnection = function(id, name) { }; -/** - * Attempts to login the given user using the given password, throwing an - * error if the process fails. - * - * @param {String} username The name of the user to login as. - * @param {String} password The password to use to authenticate the user. - */ -GuacamoleRootUI.login = function(username, password) { - - // Get username and password from form - var data = - "username=" + encodeURIComponent(username) - + "&password=" + encodeURIComponent(password) - - // Include query parameters in submission data - if (GuacamoleRootUI.parameters) - data += "&" + GuacamoleRootUI.parameters; - - // Log in - var xhr = new XMLHttpRequest(); - xhr.open("POST", "login", false); - xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - xhr.send(data); - - // Handle failures - if (xhr.status != 200) - throw new Error("Invalid login"); - -}; - /** * Set of all thumbnailed connections, indexed by ID. Here, each connection * is a GuacamoleRootUI.RecentConnection. @@ -376,7 +346,7 @@ GuacamoleRootUI.sections.login_form.onsubmit = function() { GuacUI.removeClass(GuacamoleRootUI.views.login, "error"); // Attempt login - GuacamoleRootUI.login( + GuacamoleService.Auth.login( GuacamoleRootUI.fields.username.value, GuacamoleRootUI.fields.password.value ); diff --git a/guacamole/src/main/webapp/scripts/service.js b/guacamole/src/main/webapp/scripts/service.js index fef93bd99..500e6abe4 100644 --- a/guacamole/src/main/webapp/scripts/service.js +++ b/guacamole/src/main/webapp/scripts/service.js @@ -363,156 +363,17 @@ GuacamoleService.Connections = { * Returns the root connection group, containing a hierarchy of all other * groups and connections for which the current user has access. * - * @param {String} parameters Any parameters which should be passed to the - * server for the sake of authentication - * (optional). * @return {GuacamoleService.ConnectionGroup} The root group, containing * a hierarchy of all other * groups and connections to * which the current user has * access. */ - "list" : function(parameters) { - - /** - * Parse the contents of the given connection element within XML, - * returning a corresponding GuacamoleService.Connection. - * - * @param {GuacamoleService.ConnectionGroup} The connection group - * containing this connection. - * @param {Element} element The element being parsed. - * @return {GuacamoleService.Connection} The connection represented by - * the element just parsed. - */ - function parseConnection(parent, element) { - - var i; - - var connection = new GuacamoleService.Connection( - element.getAttribute("protocol"), - element.getAttribute("id"), - element.getAttribute("name") - ); - - // Set parent - connection.parent = parent; - - // Add parameter values for each parmeter received - var paramElements = element.getElementsByTagName("param"); - for (i=0; i} + * An object mapping the names of all available protocols to + * their corresponding details. */ - "list" : function(parameters) { + "list" : function() { // Construct request URL - var list_url = "protocols"; - if (parameters) list_url += "?" + parameters; + var list_url = "api/protocol" + + "?token=" + GuacamoleService.Auth.current().authToken; // Get permission list var xhr = new XMLHttpRequest(); @@ -1317,98 +1025,7 @@ GuacamoleService.Protocols = { // Handle response GuacamoleService.handleResponse(xhr); - - // Array of all protocols - var protocols = []; - - // Parse all protocols - var protocolElements = xhr.responseXML.getElementsByTagName("protocol"); - for (var i=0; i