users: Pass more information to password checker
Passing the username and the old password allows the password quality check find more bad passwords. Also, add a way to provide more information about why a password is not good enough. https://bugzilla.gnome.org/show_bug.cgi?id=676396
This commit is contained in:
parent
810f29b6ce
commit
f62d801656
3 changed files with 22 additions and 4 deletions
|
@ -76,22 +76,27 @@ pw_generate (void)
|
|||
|
||||
gdouble
|
||||
pw_strength (const gchar *password,
|
||||
const gchar **hint)
|
||||
const gchar *old_password,
|
||||
const gchar *username,
|
||||
const gchar **hint,
|
||||
const gchar **long_hint)
|
||||
{
|
||||
gint rv;
|
||||
gdouble strength;
|
||||
void *auxerror;
|
||||
|
||||
rv = pwquality_check (get_pwq (),
|
||||
password, NULL, NULL,
|
||||
password, old_password, username,
|
||||
&auxerror);
|
||||
|
||||
if (rv == PWQ_ERROR_MIN_LENGTH) {
|
||||
*hint = C_("Password strength", "Too short");
|
||||
*long_hint = pwquality_strerror (NULL, 0, rv, auxerror);
|
||||
return 0.0;
|
||||
}
|
||||
else if (rv < 0) {
|
||||
*hint = C_("Password strength", "Not good enough");
|
||||
*long_hint = pwquality_strerror (NULL, 0, rv, auxerror);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
@ -106,5 +111,7 @@ pw_strength (const gchar *password,
|
|||
else
|
||||
*hint = C_("Password strength", "Strong");
|
||||
|
||||
*long_hint = NULL;
|
||||
|
||||
return strength;
|
||||
}
|
||||
|
|
|
@ -24,4 +24,7 @@
|
|||
gint pw_min_length (void);
|
||||
gchar *pw_generate (void);
|
||||
gdouble pw_strength (const gchar *password,
|
||||
const gchar **hint);
|
||||
const gchar *old_password,
|
||||
const gchar *username,
|
||||
const gchar **hint,
|
||||
const gchar **long_hints);
|
||||
|
|
|
@ -314,15 +314,23 @@ static void
|
|||
update_password_strength (UmPasswordDialog *um)
|
||||
{
|
||||
const gchar *password;
|
||||
const gchar *old_password;
|
||||
const gchar *username;
|
||||
gdouble strength;
|
||||
const gchar *hint;
|
||||
const gchar *long_hint;
|
||||
|
||||
password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
|
||||
old_password = gtk_entry_get_text (GTK_ENTRY (um->old_password_entry));
|
||||
username = um_user_get_user_name (um->user);
|
||||
|
||||
strength = pw_strength (password, &hint);
|
||||
strength = pw_strength (password, old_password, username,
|
||||
&hint, &long_hint);
|
||||
|
||||
cc_strength_bar_set_fraction (CC_STRENGTH_BAR (um->strength_indicator), strength);
|
||||
gtk_label_set_label (GTK_LABEL (um->strength_indicator_label), hint);
|
||||
gtk_widget_set_tooltip_text (um->strength_indicator, long_hint);
|
||||
gtk_widget_set_tooltip_text (um->strength_indicator_label, long_hint);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Reference in a new issue