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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue