summaryrefslogtreecommitdiff
path: root/daemon/gdm-session-worker.c
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2020-11-24 18:24:34 +0100
committerMarco Trevisan <mail@3v1n0.net>2020-12-21 15:18:02 +0000
commite2f3b1a56a3c2041c22fad3e82086c8a31988a9a (patch)
tree0b0e6dc1e613b6b5d99fc51a1d900ac7f7a8c18c /daemon/gdm-session-worker.c
parent39bf1df0620f4942a843f747474d78f13d9983ea (diff)
downloadgdm-e2f3b1a56a3c2041c22fad3e82086c8a31988a9a.tar.gz
session-worker: Mention the authentication method (if known) on error messages
When we use a gdm well known authentication method, we can be a bit more clear when showing the error to the user on what explicitly failed. So add functions to get the friendly error message per authentication method. To make them clearer for translators, I've added some repeated strings as generating them could lead to misleading results in some locales.
Diffstat (limited to 'daemon/gdm-session-worker.c')
-rw-r--r--daemon/gdm-session-worker.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 8d9aca78..162c1a9f 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -744,7 +744,50 @@ gdm_session_worker_process_pam_message (GdmSessionWorker *worker,
}
static const char *
-get_friendly_error_message (int error_code)
+get_max_retries_error_message (GdmSessionWorker *worker)
+{
+ if (g_strcmp0 (worker->priv->service, "gdm-password") == 0)
+ return _("You reached the maximum password authentication attempts, please try another method");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-pin") == 0)
+ return _("You reached the maximum PIN authentication attempts, please try another method");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-autologin") == 0)
+ return _("You reached the maximum auto login attempts, please try another authentication method");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-fingerprint") == 0)
+ return _("You reached the maximum fingerprint authentication attempts, please try another method");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-smartcard") == 0)
+ return _("You reached the maximum smart card authentication attempts, please try another method");
+
+ return _("You reached the maximum authentication attempts, please try another method");
+}
+
+static const char *
+get_generic_error_message (GdmSessionWorker *worker)
+{
+ if (g_strcmp0 (worker->priv->service, "gdm-password") == 0)
+ return _("Sorry, password authentication didn’t work. Please try again.");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-pin") == 0)
+ return _("Sorry, PIN authentication didn’t work. Please try again.");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-autologin") == 0)
+ return _("Sorry, auto login, didn’t work. Please try again.");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-fingerprint") == 0)
+ return _("Sorry, fingerprint authentication didn’t work. Please try again.");
+
+ if (g_strcmp0 (worker->priv->service, "gdm-smartcard") == 0)
+ return _("Sorry, smart card authentication didn’t work. Please try again.");
+
+ return _("Sorry, that didn’t work. Please try again.");
+}
+
+static const char *
+get_friendly_error_message (GdmSessionWorker *worker,
+ int error_code)
{
switch (error_code) {
case PAM_SUCCESS:
@@ -758,13 +801,13 @@ get_friendly_error_message (int error_code)
break;
case PAM_MAXTRIES:
- return _("You reached the maximum authentication attempts, please try another method");
+ return get_max_retries_error_message (worker);
default:
break;
}
- return _("Sorry, that didn’t work. Please try again.");
+ return get_generic_error_message (worker);
}
static int
@@ -1254,7 +1297,7 @@ gdm_session_worker_authenticate_user (GdmSessionWorker *worker,
g_set_error (error,
GDM_SESSION_WORKER_ERROR,
GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- "%s", get_friendly_error_message (error_code));
+ "%s", get_friendly_error_message (worker, error_code));
goto out;
}
@@ -1319,7 +1362,7 @@ gdm_session_worker_authorize_user (GdmSessionWorker *worker,
g_set_error (error,
GDM_SESSION_WORKER_ERROR,
GDM_SESSION_WORKER_ERROR_AUTHORIZING,
- "%s", get_friendly_error_message (error_code));
+ "%s", get_friendly_error_message (worker, error_code));
goto out;
}