From: Chris Koying Browet Date: Thu, 5 Dec 2019 14:34:18 +0000 (+0100) Subject: Expand password dialog to work for usernames too X-Git-Tag: v1.2.0~61 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=5b453ed4a8593d68cc4e535ef6b5614c59ff4a4d;hp=b39caa7469ee47cafc26087b9a50cbe40bbe44ae;p=mirror_novnc.git Expand password dialog to work for usernames too Some VNC authentication schemes use usernames, our UI should support these. --- diff --git a/app/styles/base.css b/app/styles/base.css index cd55e76..9db83bf 100644 --- a/app/styles/base.css +++ b/app/styles/base.css @@ -790,19 +790,23 @@ select:active { * ---------------------------------------- */ -#noVNC_password_dlg { +#noVNC_credentials_dlg { position: relative; transform: translateY(-50px); } -#noVNC_password_dlg.noVNC_open { +#noVNC_credentials_dlg.noVNC_open { transform: translateY(0); } -#noVNC_password_dlg ul { +#noVNC_credentials_dlg ul { list-style: none; margin: 0px; padding: 0px; } +.noVNC_hidden { + display: none; +} + /* ---------------------------------------- * Main Area diff --git a/app/ui.js b/app/ui.js index ddd0a49..7651d3e 100644 --- a/app/ui.js +++ b/app/ui.js @@ -316,8 +316,8 @@ const UI = { document.getElementById("noVNC_cancel_reconnect_button") .addEventListener('click', UI.cancelReconnect); - document.getElementById("noVNC_password_button") - .addEventListener('click', UI.setPassword); + document.getElementById("noVNC_credentials_button") + .addEventListener('click', UI.setCredentials); }, addClipboardHandlers() { @@ -440,7 +440,7 @@ const UI = { } // State change closes the password dialog - document.getElementById('noVNC_password_dlg') + document.getElementById('noVNC_credentials_dlg') .classList.remove('noVNC_open'); }, @@ -1147,27 +1147,46 @@ const UI = { credentials(e) { // FIXME: handle more types - document.getElementById('noVNC_password_dlg') + + document.getElementById("noVNC_username_block").classList.remove("noVNC_hidden"); + document.getElementById("noVNC_password_block").classList.remove("noVNC_hidden"); + + let inputFocus = "none"; + if (!e.detail.types.includes("username")) { + document.getElementById("noVNC_username_block").classList.add("noVNC_hidden"); + } else { + inputFocus = inputFocus === "none" ? "noVNC_username_input" : inputFocus; + } + if (!e.detail.types.includes("password")) { + document.getElementById("noVNC_password_block").classList.add("noVNC_hidden"); + } else { + inputFocus = inputFocus === "none" ? "noVNC_password_input" : inputFocus; + } + document.getElementById('noVNC_credentials_dlg') .classList.add('noVNC_open'); setTimeout(() => document - .getElementById('noVNC_password_input').focus(), 100); + .getElementById(inputFocus).focus(), 100); - Log.Warn("Server asked for a password"); - UI.showStatus(_("Password is required"), "warning"); + Log.Warn("Server asked for credentials"); + UI.showStatus(_("Credentials are required"), "warning"); }, - setPassword(e) { + setCredentials(e) { // Prevent actually submitting the form e.preventDefault(); - const inputElem = document.getElementById('noVNC_password_input'); - const password = inputElem.value; + let inputElemUsername = document.getElementById('noVNC_username_input'); + const username = inputElemUsername.value; + + let inputElemPassword = document.getElementById('noVNC_password_input'); + const password = inputElemPassword.value; // Clear the input after reading the password - inputElem.value = ""; - UI.rfb.sendCredentials({ password: password }); + inputElemPassword.value = ""; + + UI.rfb.sendCredentials({ username: username, password: password }); UI.reconnect_password = password; - document.getElementById('noVNC_password_dlg') + document.getElementById('noVNC_credentials_dlg') .classList.remove('noVNC_open'); }, diff --git a/vnc.html b/vnc.html index c3fef0c..52fb1f3 100644 --- a/vnc.html +++ b/vnc.html @@ -285,14 +285,18 @@
-
+
    -
  • +
  • + + +
  • +
  • - +