Better code
authorKarl O. Pinc <kop@karlpinc.com>
Fri, 30 Apr 2021 04:04:05 +0000 (23:04 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Fri, 30 Apr 2021 04:04:05 +0000 (23:04 -0500)
src/pgwui_core/core.py

index 7764e9b2bdf71f7e641892eefc803d7933d75224..8bc424d7cd9a4a29240a8707837eab14fce145d2 100644 (file)
@@ -320,16 +320,15 @@ class CredsLoadedForm(LoadedForm):
         Produces the dict pyramid will use to render the form.
         '''
         response = super().write(result, errors)
-        if ('havecreds' not in response
-                or ('havecreds' in response and not response['havecreds'])):
+        if response.get('havecreds', False):
+            response['user'] = self['user']
+        else:
             # We don't know if the credentials are good or
             # we know they are bad.  Keep them out of the session.
             response['user'] = ''
             response['password'] = ''
             self.session_put('user', '')
             self.session_put('password', '')
-        else:
-            response['user'] = self['user']
         return response