[f19-branch/master 1/2] Show User password strength during entry

Brian C. Lane bcl at redhat.com
Mon Jun 3 18:08:26 UTC 2013


From: "Brian C. Lane" <bcl at redhat.com>

The user password entry wasn't updating the strength until the
confirmation password was entered. This changes it so that it will
update while the first password is entered, and will leave the strength
showing while the confirmation is entered.
---
 pyanaconda/ui/gui/spokes/user.py | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py
index 2c9cd1b..aab5d3c 100644
--- a/pyanaconda/ui/gui/spokes/user.py
+++ b/pyanaconda/ui/gui/spokes/user.py
@@ -315,27 +315,14 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke):
         to the passwords entered by the user. It is called by
         the changed Gtk event handler.
         """
-        if self.pw.get_text() == "":
-            strength = -2
-        elif self.pw.get_text() != self.confirm.get_text():
-            strength = -1
-        else:
-            try:
-                strength = self._pwq.check(self.pw.get_text(), None, None)
-                _pwq_error = None
-            except pwquality.PWQError as (e, msg):
-                _pwq_error = msg
-                strength = 0
-
-        if strength == -1:
-            val = 0
-            text = _("Mismatch!")
-            self._error = _("The passwords do not match!")
-        elif strength == -2:
-            val = 0
-            text = _("Empty!")
-            self._error = _("The password is empty!")
-        elif strength < 50:
+        try:
+            strength = self._pwq.check(self.pw.get_text(), None, None)
+            _pwq_error = None
+        except pwquality.PWQError as (e, msg):
+            _pwq_error = msg
+            strength = 0
+
+        if strength < 50:
             val = 1
             text = _("Weak")
             self._error = _("The password you have provided is weak")
@@ -357,6 +344,13 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke):
             text = _("Strong")
             self._error = False
 
+        if not self.pw.get_text():
+            val = 0
+            text = _("Empty!")
+            self._error = _("The password is empty!")
+        elif self.confirm.get_text() and self.pw.get_text() != self.confirm.get_text():
+            self._error = _("The passwords do not match!")
+
         self.pw_bar.set_value(val)
         self.pw_label.set_text(text)
 
-- 
1.8.1.4



More information about the anaconda-patches mailing list