[gnome-control-center/T20818: 34/54] user-accounts: Allow to remove the password for a user
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/T20818: 34/54] user-accounts: Allow to remove the password for a user
- Date: Tue, 23 Jan 2018 21:32:53 +0000 (UTC)
commit e1911471162ad1fe57bd5204b43f2696f322b715
Author: Joaquim Rocha <jrocha endlessm com>
Date: Fri Jun 9 17:40:14 2017 +0200
user-accounts: Allow to remove the password for a user
Since we now support users without passwords, admin users should be
able to set that option for existing users when changing their password.
https://phabricator.endlessm.com/T17270
panels/user-accounts/data/password-dialog.ui | 16 +++++++-
panels/user-accounts/um-password-dialog.c | 57 +++++++++++++++++++++----
2 files changed, 63 insertions(+), 10 deletions(-)
---
diff --git a/panels/user-accounts/data/password-dialog.ui b/panels/user-accounts/data/password-dialog.ui
index f96752f..984f94a 100644
--- a/panels/user-accounts/data/password-dialog.ui
+++ b/panels/user-accounts/data/password-dialog.ui
@@ -252,6 +252,20 @@
</packing>
</child>
<child>
+ <object class="GtkRadioButton" id="action-no-password-radio">
+ <property name="label" translatable="yes">Allow user to log in without a
password</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">action-login-radio</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkRadioButton" id="action-now-radio">
<property name="label" translatable="yes">Set a password now</property>
<property name="visible">True</property>
@@ -262,7 +276,7 @@
<property name="group">action-login-radio</property>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/panels/user-accounts/um-password-dialog.c b/panels/user-accounts/um-password-dialog.c
index 6ff7b0c..ad2e33f 100644
--- a/panels/user-accounts/um-password-dialog.c
+++ b/panels/user-accounts/um-password-dialog.c
@@ -42,6 +42,7 @@ struct _UmPasswordDialog {
GtkWidget *action_radio_box;
GtkWidget *action_now_radio;
GtkWidget *action_login_radio;
+ GtkWidget *action_no_password_radio;
GtkWidget *password_entry;
GtkWidget *verify_entry;
gint password_entry_timeout_id;
@@ -222,6 +223,14 @@ accept_password_dialog (GtkButton *button,
act_user_set_automatic_login (um->user, FALSE);
break;
+ case ACT_USER_PASSWORD_MODE_NONE:
+ /* When setting the user password mode to none, when it
+ * was previously set-at-login, we need to reset the password,
+ * otherwise the mode will be set back to set-at-login */
+ act_user_set_password (um->user, "", "");
+ act_user_set_password_mode (um->user, um->password_mode);
+ break;
+
default:
g_assert_not_reached ();
}
@@ -263,25 +272,48 @@ mode_change (UmPasswordDialog *um,
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);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (um->action_login_radio),
+ (mode == ACT_USER_PASSWORD_MODE_SET_AT_LOGIN));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (um->action_no_password_radio),
+ (mode == ACT_USER_PASSWORD_MODE_NONE));
um->password_mode = mode;
update_sensitivity (um);
}
static void
-action_changed (GtkRadioButton *radio,
- UmPasswordDialog *um)
+set_password_mode_from_radio_button (GtkRadioButton *radio,
+ UmPasswordDialog *um,
+ ActUserPasswordMode mode)
{
- gint active;
- ActUserPasswordMode mode;
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
+ return;
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
- mode = active ? ACT_USER_PASSWORD_MODE_REGULAR : ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
mode_change (um, mode);
}
static void
+password_now_radio_toggled_cb (GtkRadioButton *radio,
+ UmPasswordDialog *um)
+{
+ set_password_mode_from_radio_button (radio, um, ACT_USER_PASSWORD_MODE_REGULAR);
+}
+
+static void
+no_password_radio_toggled_cb (GtkRadioButton *radio,
+ UmPasswordDialog *um)
+{
+ set_password_mode_from_radio_button (radio, um, ACT_USER_PASSWORD_MODE_NONE);
+}
+
+static void
+password_login_radio_toggled_cb (GtkRadioButton *radio,
+ UmPasswordDialog *um)
+{
+ set_password_mode_from_radio_button (radio, um, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN);
+}
+
+static void
update_password_match (UmPasswordDialog *um)
{
const char *password;
@@ -462,9 +494,16 @@ um_password_dialog_new (void)
um->action_radio_box = (GtkWidget *) gtk_builder_get_object (builder, "action-radio-box");
widget = (GtkWidget *) gtk_builder_get_object (builder, "action-now-radio");
- g_signal_connect (widget, "toggled", G_CALLBACK (action_changed), um);
+ g_signal_connect (widget, "toggled", G_CALLBACK (password_now_radio_toggled_cb), um);
um->action_now_radio = widget;
- um->action_login_radio = (GtkWidget *) gtk_builder_get_object (builder, "action-login-radio");
+
+ widget = (GtkWidget *) gtk_builder_get_object (builder, "action-login-radio");
+ g_signal_connect (widget, "toggled", G_CALLBACK (password_login_radio_toggled_cb), um);
+ um->action_login_radio = widget;
+
+ widget = (GtkWidget *) gtk_builder_get_object (builder, "action-no-password-radio");
+ g_signal_connect (widget, "toggled", G_CALLBACK (no_password_radio_toggled_cb), um);
+ um->action_no_password_radio = widget;
widget = (GtkWidget *) gtk_builder_get_object (builder, "dialog");
g_signal_connect (widget, "delete-event",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]