summaryrefslogtreecommitdiffstats
path: root/src/virt-viewer-session-spice.c
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2014-10-06 13:58:04 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-10-10 12:57:08 +0200
commit9886055a4a7e44ee5080fbcbae0b99eeb69ff2d2 (patch)
treef9ae905c7359b26d5a292ab12d63e1d48a528b9c /src/virt-viewer-session-spice.c
parent69b3096f51bf2b6e9d1606b9fd49499899886ac7 (diff)
downloadvirt-viewer-9886055a4a7e44ee5080fbcbae0b99eeb69ff2d2.tar.gz
virt-viewer-9886055a4a7e44ee5080fbcbae0b99eeb69ff2d2.tar.xz
virt-viewer-9886055a4a7e44ee5080fbcbae0b99eeb69ff2d2.zip
Prefill the username in the authentication dialog
Lets prefill the username entry using the user name of the current user.
Diffstat (limited to 'src/virt-viewer-session-spice.c')
-rw-r--r--src/virt-viewer-session-spice.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 0c841bf..c45795c 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -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",