mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 14:54:14 +00:00
Prefill the username in the authentication dialog
Lets prefill the username entry using the user name of the current user.
This commit is contained in:
parent
69b3096f51
commit
9886055a4a
@ -714,6 +714,9 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
|
||||
"username", &username,
|
||||
NULL);
|
||||
|
||||
if (username == NULL || *username == '\0')
|
||||
username = g_strdup(g_get_user_name());
|
||||
|
||||
window = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(user_data));
|
||||
success = virt_viewer_auth_collect_credentials(virt_viewer_window_get_window(window),
|
||||
"oVirt",
|
||||
|
||||
@ -528,13 +528,17 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
|
||||
error != NULL ? error->message : _("Invalid password"));
|
||||
self->priv->pass_try++;
|
||||
|
||||
/* A username is *only* pre-filled in case where some authentication
|
||||
* error happened. Unfortunately, we don't have a clear way to
|
||||
* differantiate between invalid username and invalid password.
|
||||
* So, in both cases the username entry will be pre-filled with the
|
||||
* username used in the previous attempt. */
|
||||
if (username_required)
|
||||
/* The username is firstly pre-filled with the username of the current
|
||||
* user and in case where some authentication error happened, the
|
||||
* username entry will be prefilled with the last username used.
|
||||
* Unfortunately, we don't have a clear way to differantiate bewteen
|
||||
* invalid username and invalid password. So, in both cases the username
|
||||
* entry will be pre-filled with the username used in the previous attempt. */
|
||||
if (username_required) {
|
||||
g_object_get(self->priv->session, "username", &user, NULL);
|
||||
if (user == NULL || *user == '\0')
|
||||
user = g_strdup(g_get_user_name());
|
||||
}
|
||||
|
||||
ret = virt_viewer_auth_collect_credentials(self->priv->main_window,
|
||||
"SPICE",
|
||||
|
||||
@ -283,9 +283,13 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED,
|
||||
|
||||
VirtViewerFile *file = virt_viewer_session_get_file(VIRT_VIEWER_SESSION(self));
|
||||
if (file != NULL) {
|
||||
if (wantUsername && virt_viewer_file_is_set(file, "username")) {
|
||||
username = virt_viewer_file_get_username(file);
|
||||
wantUsername = FALSE;
|
||||
if (wantUsername) {
|
||||
if (virt_viewer_file_is_set(file, "username")) {
|
||||
username = virt_viewer_file_get_username(file);
|
||||
wantUsername = FALSE;
|
||||
} else {
|
||||
username = g_strdup(g_get_user_name());
|
||||
}
|
||||
}
|
||||
if (wantPassword && virt_viewer_file_is_set(file, "password")) {
|
||||
password = virt_viewer_file_get_password(file);
|
||||
|
||||
@ -711,6 +711,10 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
|
||||
if (username || password) {
|
||||
VirtViewerWindow *vwin = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(app));
|
||||
GtkWindow *win = virt_viewer_window_get_window(vwin);
|
||||
|
||||
if (*username == NULL || **username == '\0')
|
||||
*username = g_strdup(g_get_user_name());
|
||||
|
||||
priv->auth_cancelled = !virt_viewer_auth_collect_credentials(win,
|
||||
"libvirt",
|
||||
app->priv->uri,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user