summaryrefslogtreecommitdiff
path: root/app/ui.js
diff options
context:
space:
mode:
authorChris Koying Browet <cbro@semperpax.com>2019-12-05 15:34:18 +0100
committerSamuel Mannehed <samuel@cendio.se>2019-12-05 15:46:24 +0100
commit5b453ed4a8593d68cc4e535ef6b5614c59ff4a4d (patch)
tree969f6ed5b3624fd2aed610f89d0bca9214ec8937 /app/ui.js
parentb39caa7469ee47cafc26087b9a50cbe40bbe44ae (diff)
downloadnovnc-5b453ed4a8593d68cc4e535ef6b5614c59ff4a4d.tar.gz
Expand password dialog to work for usernames too
Some VNC authentication schemes use usernames, our UI should support these.
Diffstat (limited to 'app/ui.js')
-rw-r--r--app/ui.js45
1 files changed, 32 insertions, 13 deletions
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');
},