Expand password dialog to work for usernames too
Some VNC authentication schemes use usernames, our UI should support these.
This commit is contained in:
parent
b39caa7469
commit
5b453ed4a8
|
@ -790,19 +790,23 @@ select:active {
|
||||||
* ----------------------------------------
|
* ----------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#noVNC_password_dlg {
|
#noVNC_credentials_dlg {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
transform: translateY(-50px);
|
transform: translateY(-50px);
|
||||||
}
|
}
|
||||||
#noVNC_password_dlg.noVNC_open {
|
#noVNC_credentials_dlg.noVNC_open {
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
#noVNC_password_dlg ul {
|
#noVNC_credentials_dlg ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
.noVNC_hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------
|
/* ----------------------------------------
|
||||||
* Main Area
|
* Main Area
|
||||||
|
|
45
app/ui.js
45
app/ui.js
|
@ -316,8 +316,8 @@ const UI = {
|
||||||
document.getElementById("noVNC_cancel_reconnect_button")
|
document.getElementById("noVNC_cancel_reconnect_button")
|
||||||
.addEventListener('click', UI.cancelReconnect);
|
.addEventListener('click', UI.cancelReconnect);
|
||||||
|
|
||||||
document.getElementById("noVNC_password_button")
|
document.getElementById("noVNC_credentials_button")
|
||||||
.addEventListener('click', UI.setPassword);
|
.addEventListener('click', UI.setCredentials);
|
||||||
},
|
},
|
||||||
|
|
||||||
addClipboardHandlers() {
|
addClipboardHandlers() {
|
||||||
|
@ -440,7 +440,7 @@ const UI = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// State change closes the password dialog
|
// State change closes the password dialog
|
||||||
document.getElementById('noVNC_password_dlg')
|
document.getElementById('noVNC_credentials_dlg')
|
||||||
.classList.remove('noVNC_open');
|
.classList.remove('noVNC_open');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1147,27 +1147,46 @@ const UI = {
|
||||||
|
|
||||||
credentials(e) {
|
credentials(e) {
|
||||||
// FIXME: handle more types
|
// 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');
|
.classList.add('noVNC_open');
|
||||||
|
|
||||||
setTimeout(() => document
|
setTimeout(() => document
|
||||||
.getElementById('noVNC_password_input').focus(), 100);
|
.getElementById(inputFocus).focus(), 100);
|
||||||
|
|
||||||
Log.Warn("Server asked for a password");
|
Log.Warn("Server asked for credentials");
|
||||||
UI.showStatus(_("Password is required"), "warning");
|
UI.showStatus(_("Credentials are required"), "warning");
|
||||||
},
|
},
|
||||||
|
|
||||||
setPassword(e) {
|
setCredentials(e) {
|
||||||
// Prevent actually submitting the form
|
// Prevent actually submitting the form
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const inputElem = document.getElementById('noVNC_password_input');
|
let inputElemUsername = document.getElementById('noVNC_username_input');
|
||||||
const password = inputElem.value;
|
const username = inputElemUsername.value;
|
||||||
|
|
||||||
|
let inputElemPassword = document.getElementById('noVNC_password_input');
|
||||||
|
const password = inputElemPassword.value;
|
||||||
// Clear the input after reading the password
|
// Clear the input after reading the password
|
||||||
inputElem.value = "";
|
inputElemPassword.value = "";
|
||||||
UI.rfb.sendCredentials({ password: password });
|
|
||||||
|
UI.rfb.sendCredentials({ username: username, password: password });
|
||||||
UI.reconnect_password = password;
|
UI.reconnect_password = password;
|
||||||
document.getElementById('noVNC_password_dlg')
|
document.getElementById('noVNC_credentials_dlg')
|
||||||
.classList.remove('noVNC_open');
|
.classList.remove('noVNC_open');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
10
vnc.html
10
vnc.html
|
@ -285,14 +285,18 @@
|
||||||
|
|
||||||
<!-- Password Dialog -->
|
<!-- Password Dialog -->
|
||||||
<div class="noVNC_center noVNC_connect_layer">
|
<div class="noVNC_center noVNC_connect_layer">
|
||||||
<div id="noVNC_password_dlg" class="noVNC_panel"><form>
|
<div id="noVNC_credentials_dlg" class="noVNC_panel"><form>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li id="noVNC_username_block">
|
||||||
|
<label>Username:</label>
|
||||||
|
<input id="noVNC_username_input">
|
||||||
|
</li>
|
||||||
|
<li id="noVNC_password_block">
|
||||||
<label>Password:</label>
|
<label>Password:</label>
|
||||||
<input id="noVNC_password_input" type="password">
|
<input id="noVNC_password_input" type="password">
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input id="noVNC_password_button" type="submit" value="Send Password" class="noVNC_submit">
|
<input id="noVNC_credentials_button" type="submit" value="Send Credentials" class="noVNC_submit">
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</form></div>
|
</form></div>
|
||||||
|
|
Loading…
Reference in New Issue