[gnome-initial-setup] password: Add strength indicator level for weak passwords



commit 2ca5f06db8d84924b9d289fffd2f1f0e89ad7acc
Author: Ondrej Holy <oholy redhat com>
Date:   Tue May 30 10:47:50 2017 +0200

    password: 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=783236

 .../pages/password/gis-password-page.c             |    2 +-
 .../pages/password/gis-password-page.ui            |    9 ++++++++-
 gnome-initial-setup/pages/password/pw-utils.c      |   14 +++++++++-----
 3 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/gnome-initial-setup/pages/password/gis-password-page.c 
b/gnome-initial-setup/pages/password/gis-password-page.c
index 6afbed8..13c2eff 100644
--- a/gnome-initial-setup/pages/password/gis-password-page.c
+++ b/gnome-initial-setup/pages/password/gis-password-page.c
@@ -132,7 +132,7 @@ validate (GisPasswordPage *page)
   gtk_label_set_label (GTK_LABEL (priv->confirm_explanation), "");
   priv->valid_confirm = FALSE;
 
-  priv->valid_password = (strength_level > 0);
+  priv->valid_password = (strength_level > 1);
   if (priv->valid_password)
     set_entry_validation_checkmark (GTK_ENTRY (priv->password_entry));
 
diff --git a/gnome-initial-setup/pages/password/gis-password-page.ui 
b/gnome-initial-setup/pages/password/gis-password-page.ui
index 4c3c138..e655124 100644
--- a/gnome-initial-setup/pages/password/gis-password-page.ui
+++ b/gnome-initial-setup/pages/password/gis-password-page.ui
@@ -127,8 +127,15 @@
                 <property name="can_focus">False</property>
                 <property name="halign">fill</property>
                 <property name="valign">center</property>
-                <property name="max-value">4</property>
+                <property name="max-value">5</property>
                 <property name="mode">discrete</property>
+                <offsets>
+                  <offset name="strength-weak" value="1"/>
+                  <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>
               </object>
               <packing>
                 <property name="left_attach">1</property>
diff --git a/gnome-initial-setup/pages/password/pw-utils.c b/gnome-initial-setup/pages/password/pw-utils.c
index 338ca0c..fd77f80 100644
--- a/gnome-initial-setup/pages/password/pw-utils.c
+++ b/gnome-initial-setup/pages/password/pw-utils.c
@@ -127,7 +127,7 @@ pw_strength (const gchar  *password,
              const gchar **hint,
              gint         *strength_level)
 {
-        gint rv, level = 0;
+        gint rv, level, length = 0;
         gdouble strength = 0.0;
         void *auxerror;
 
@@ -135,17 +135,21 @@ pw_strength (const gchar  *password,
                               password, old_password, username,
                               &auxerror);
 
+        if (password != NULL)
+                length = strlen (password);
+
         strength = CLAMP (0.01 * rv, 0.0, 1.0);
         if (rv < 0) {
+                level = (length > 0) ? 1 : 0;
         }
         else if (strength < 0.50) {
-                level = 1;
-        } else if (strength < 0.75) {
                 level = 2;
-        } else if (strength < 0.90) {
+        } else if (strength < 0.75) {
                 level = 3;
-        } else {
+        } else if (strength < 0.90) {
                 level = 4;
+        } else {
+                level = 5;
         }
 
         *hint = pw_error_hint (rv);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]