[gnome-control-center/T20771: 19/44] user-accounts: Allow to set up a password reminder
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/T20771: 19/44] user-accounts: Allow to set up a password reminder
- Date: Tue, 23 Jan 2018 21:08:10 +0000 (UTC)
commit e2886904bf628156d73b062655ebfb75576848a7
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Mon Mar 28 12:18:39 2016 -0700
user-accounts: Allow to set up a password reminder
When setting up user password, allow to set up also a password reminder phrase,
that can be used to remind the user what is the password.
[endlessm/eos-shell#1623]
panels/user-accounts/data/account-dialog.ui | 27 +++++++++++++++++++++++++
panels/user-accounts/data/password-dialog.ui | 28 ++++++++++++++++++++++++++
panels/user-accounts/um-account-dialog.c | 23 +++++++++++++-------
panels/user-accounts/um-password-dialog.c | 22 ++++++++++++++++++-
4 files changed, 90 insertions(+), 10 deletions(-)
---
diff --git a/panels/user-accounts/data/account-dialog.ui b/panels/user-accounts/data/account-dialog.ui
index a508ecd..eb97e86 100644
--- a/panels/user-accounts/data/account-dialog.ui
+++ b/panels/user-accounts/data/account-dialog.ui
@@ -442,6 +442,33 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Password _Reminder</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">local_reminder</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">11</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="local_reminder">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">11</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="name">_local</property>
diff --git a/panels/user-accounts/data/password-dialog.ui b/panels/user-accounts/data/password-dialog.ui
index 283f703..f96752f 100644
--- a/panels/user-accounts/data/password-dialog.ui
+++ b/panels/user-accounts/data/password-dialog.ui
@@ -272,6 +272,34 @@
<property name="width">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="password-reminder-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Password _Reminder</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">password-reminder-entry</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="password-reminder-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index caa65c7..06b4fc2 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -93,6 +93,7 @@ struct _UmAccountDialog {
GtkWidget *local_strength_indicator;
GtkWidget *local_hint;
GtkWidget *local_verify_hint;
+ GtkWidget *local_reminder;
/* Enterprise widgets */
guint realmd_watch;
@@ -196,17 +197,21 @@ user_loaded_cb (ActUser *user,
GParamSpec *pspec,
UmAccountDialog *self)
{
- const gchar *password;
+ const gchar *password;
+ const gchar *reminder;
+
+ finish_action (self);
- finish_action (self);
+ password = gtk_entry_get_text (GTK_ENTRY (self->local_password));
+ reminder = gtk_entry_get_text (GTK_ENTRY (self->local_reminder));
+ act_user_set_password_mode (user, self->local_password_mode);
- /* Set a password for the user */
- password = gtk_entry_get_text (GTK_ENTRY (self->local_password));
- act_user_set_password_mode (user, self->local_password_mode);
- if (self->local_password_mode == ACT_USER_PASSWORD_MODE_REGULAR)
- act_user_set_password (user, password, "");
+ if (self->local_password_mode == ACT_USER_PASSWORD_MODE_REGULAR) {
+ g_autofree gchar *sanitized_reminder = g_strstrip (g_strdup (reminder));
+ act_user_set_password (user, password, sanitized_reminder);
+ }
- complete_dialog (self, user);
+ complete_dialog (self, user);
}
static void
@@ -550,6 +555,7 @@ on_password_radio_changed (GtkRadioButton *radio,
gtk_widget_set_sensitive (self->local_verify, active);
gtk_widget_set_sensitive (self->local_strength_indicator, active);
gtk_widget_set_sensitive (self->local_hint, active);
+ gtk_widget_set_sensitive (self->local_reminder, active);
dialog_validate (self);
}
@@ -1574,6 +1580,7 @@ um_account_dialog_class_init (UmAccountDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_strength_indicator);
gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_hint);
gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_verify_hint);
+ gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_reminder);
gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_button);
gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, spinner);
gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_domain);
diff --git a/panels/user-accounts/um-password-dialog.c b/panels/user-accounts/um-password-dialog.c
index 64957d9..6ff7b0c 100644
--- a/panels/user-accounts/um-password-dialog.c
+++ b/panels/user-accounts/um-password-dialog.c
@@ -49,6 +49,7 @@ struct _UmPasswordDialog {
GtkWidget *ok_button;
GtkWidget *password_hint;
GtkWidget *verify_hint;
+ GtkWidget *password_reminder;
ActUser *user;
ActUserPasswordMode password_mode;
@@ -102,6 +103,7 @@ finish_password_change (UmPasswordDialog *um)
gtk_entry_set_text (GTK_ENTRY (um->password_entry), " ");
gtk_entry_set_text (GTK_ENTRY (um->verify_entry), "");
gtk_entry_set_text (GTK_ENTRY (um->old_password_entry), "");
+ gtk_entry_set_text (GTK_ENTRY (um->password_reminder), "");
um_password_dialog_set_user (um, NULL);
}
@@ -134,6 +136,12 @@ password_changed_cb (PasswdHandler *handler,
gdk_window_set_cursor (gtk_widget_get_window (um->dialog), NULL);
if (!error) {
+ g_autofree gchar *sanitized_reminder = NULL;
+ const gchar *reminder;
+
+ reminder = gtk_entry_get_text (GTK_ENTRY (um->password_reminder));
+ sanitized_reminder = g_strstrip (g_strdup (reminder));
+ act_user_set_password_hint (um->user, sanitized_reminder);
finish_password_change (um);
return;
}
@@ -176,7 +184,8 @@ static void
accept_password_dialog (GtkButton *button,
UmPasswordDialog *um)
{
- const gchar *password;
+ const gchar *password, *reminder;
+ gchar *sanitized_reminder;
password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
@@ -201,8 +210,11 @@ accept_password_dialog (GtkButton *button,
return;
}
+ reminder = gtk_entry_get_text (GTK_ENTRY (um->password_reminder));
+ sanitized_reminder = g_strstrip (g_strdup (reminder));
act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_REGULAR);
- act_user_set_password (um->user, password, "");
+ act_user_set_password (um->user, password, sanitized_reminder);
+ g_free (sanitized_reminder);
break;
case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN:
@@ -249,6 +261,7 @@ mode_change (UmPasswordDialog *um,
gtk_widget_set_sensitive (um->verify_entry, active);
gtk_widget_set_sensitive (um->old_password_entry, active);
gtk_widget_set_sensitive (um->password_hint, active);
+ gtk_widget_set_sensitive (um->password_reminder, active);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (um->action_now_radio), active);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (um->action_login_radio), !active);
@@ -503,6 +516,9 @@ um_password_dialog_new (void)
widget = (GtkWidget *)gtk_builder_get_object (builder, "verify-hint");
um->verify_hint = widget;
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "password-reminder-entry");
+ um->password_reminder = widget;
+
g_object_unref (builder);
return um;
@@ -547,6 +563,7 @@ um_password_dialog_set_user (UmPasswordDialog *um,
gtk_entry_set_text (GTK_ENTRY (um->password_entry), "");
gtk_entry_set_text (GTK_ENTRY (um->verify_entry), "");
gtk_entry_set_text (GTK_ENTRY (um->old_password_entry), "");
+ gtk_entry_set_text (GTK_ENTRY (um->password_reminder), "");
gtk_entry_set_visibility (GTK_ENTRY (um->password_entry), FALSE);
gtk_entry_set_visibility (GTK_ENTRY (um->verify_entry), FALSE);
@@ -558,6 +575,7 @@ um_password_dialog_set_user (UmPasswordDialog *um,
visible = (act_user_get_password_mode (user) != ACT_USER_PASSWORD_MODE_NONE);
gtk_widget_set_visible (um->old_password_label, visible);
gtk_widget_set_visible (um->old_password_entry, visible);
+ gtk_entry_set_text (GTK_ENTRY (um->password_reminder), act_user_get_password_hint
(user));
um->old_password_ok = !visible;
}
else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]