user-accounts: Add strength indicator level for weak passwords
Add first level for short, or weak passwords to be obvious that the strength indicator signalize something. https://bugzilla.gnome.org/show_bug.cgi?id=780002
This commit is contained in:
parent
9e4123363e
commit
e89d4f59c2
5 changed files with 23 additions and 13 deletions
|
@ -335,11 +335,14 @@
|
||||||
<object class="GtkLevelBar" id="local_strength_indicator">
|
<object class="GtkLevelBar" id="local_strength_indicator">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="mode">discrete</property>
|
<property name="mode">discrete</property>
|
||||||
<property name="max-value">4</property>
|
<property name="max-value">5</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<offsets>
|
<offsets>
|
||||||
<offset name="low" value="1"/>
|
<offset name="strength-weak" value="1"/>
|
||||||
<offset name="high" value="3"/>
|
<offset name="strength-low" value="2"/>
|
||||||
|
<offset name="strength-medium" value="3"/>
|
||||||
|
<offset name="strength-good" value="4"/>
|
||||||
|
<offset name="strength-high" value="5"/>
|
||||||
</offsets>
|
</offsets>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
|
|
@ -187,10 +187,13 @@
|
||||||
<object class="GtkLevelBar" id="strength-indicator">
|
<object class="GtkLevelBar" id="strength-indicator">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="mode">discrete</property>
|
<property name="mode">discrete</property>
|
||||||
<property name="max-value">4</property>
|
<property name="max-value">5</property>
|
||||||
<offsets>
|
<offsets>
|
||||||
<offset name="low" value="1"/>
|
<offset name="strength-weak" value="1"/>
|
||||||
<offset name="high" value="3"/>
|
<offset name="strength-low" value="2"/>
|
||||||
|
<offset name="strength-medium" value="3"/>
|
||||||
|
<offset name="strength-good" value="4"/>
|
||||||
|
<offset name="strength-high" value="5"/>
|
||||||
</offsets>
|
</offsets>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
|
|
@ -127,7 +127,7 @@ pw_strength (const gchar *password,
|
||||||
const gchar **hint,
|
const gchar **hint,
|
||||||
gint *strength_level)
|
gint *strength_level)
|
||||||
{
|
{
|
||||||
gint rv, level = 0;
|
gint rv, level, length = 0;
|
||||||
gdouble strength = 0.0;
|
gdouble strength = 0.0;
|
||||||
void *auxerror;
|
void *auxerror;
|
||||||
|
|
||||||
|
@ -135,17 +135,21 @@ pw_strength (const gchar *password,
|
||||||
password, old_password, username,
|
password, old_password, username,
|
||||||
&auxerror);
|
&auxerror);
|
||||||
|
|
||||||
|
if (password != NULL)
|
||||||
|
length = strlen (password);
|
||||||
|
|
||||||
strength = CLAMP (0.01 * rv, 0.0, 1.0);
|
strength = CLAMP (0.01 * rv, 0.0, 1.0);
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
|
level = (length > 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
else if (strength < 0.50) {
|
else if (strength < 0.50) {
|
||||||
level = 1;
|
|
||||||
} else if (strength < 0.75) {
|
|
||||||
level = 2;
|
level = 2;
|
||||||
} else if (strength < 0.90) {
|
} else if (strength < 0.75) {
|
||||||
level = 3;
|
level = 3;
|
||||||
} else {
|
} else if (strength < 0.90) {
|
||||||
level = 4;
|
level = 4;
|
||||||
|
} else {
|
||||||
|
level = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hint = pw_error_hint (rv);
|
*hint = pw_error_hint (rv);
|
||||||
|
|
|
@ -282,7 +282,7 @@ update_password_strength (UmAccountDialog *self)
|
||||||
gtk_label_set_label (GTK_LABEL (self->local_hint), hint);
|
gtk_label_set_label (GTK_LABEL (self->local_hint), hint);
|
||||||
gtk_level_bar_set_value (GTK_LEVEL_BAR (self->local_strength_indicator), strength_level);
|
gtk_level_bar_set_value (GTK_LEVEL_BAR (self->local_strength_indicator), strength_level);
|
||||||
|
|
||||||
if (strength_level > 0) {
|
if (strength_level > 1) {
|
||||||
set_entry_validation_checkmark (GTK_ENTRY (self->local_password));
|
set_entry_validation_checkmark (GTK_ENTRY (self->local_password));
|
||||||
} else if (strlen (password) == 0) {
|
} else if (strlen (password) == 0) {
|
||||||
set_entry_generation_icon (GTK_ENTRY (self->local_password));
|
set_entry_generation_icon (GTK_ENTRY (self->local_password));
|
||||||
|
|
|
@ -84,7 +84,7 @@ update_password_strength (UmPasswordDialog *um)
|
||||||
gtk_level_bar_set_value (GTK_LEVEL_BAR (um->strength_indicator), strength_level);
|
gtk_level_bar_set_value (GTK_LEVEL_BAR (um->strength_indicator), strength_level);
|
||||||
gtk_label_set_label (GTK_LABEL (um->password_hint), hint);
|
gtk_label_set_label (GTK_LABEL (um->password_hint), hint);
|
||||||
|
|
||||||
if (strength_level > 0) {
|
if (strength_level > 1) {
|
||||||
set_entry_validation_checkmark (GTK_ENTRY (um->password_entry));
|
set_entry_validation_checkmark (GTK_ENTRY (um->password_entry));
|
||||||
} else if (strlen (password) == 0) {
|
} else if (strlen (password) == 0) {
|
||||||
set_entry_generation_icon (GTK_ENTRY (um->password_entry));
|
set_entry_generation_icon (GTK_ENTRY (um->password_entry));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue