more tweaks for python3
authorparmentelat <thierry.parmentelat@inria.fr>
Fri, 14 Dec 2018 12:08:22 +0000 (13:08 +0100)
committerparmentelat <thierry.parmentelat@inria.fr>
Fri, 14 Dec 2018 12:08:22 +0000 (13:08 +0100)
PLC/Auth.py
PLC/Persons.py
PLC/Sites.py

index afde8c1..33f60c2 100644 (file)
@@ -324,7 +324,7 @@ class PasswordAuth(Auth):
                     "PasswordAuth: Maintenance account password verification failed")
         else:
             # Compare encrypted plaintext against encrypted password stored in the DB
-            plaintext = auth['AuthString'].encode(method.api.encoding)
+            plaintext = auth['AuthString']
             password = person['password']
 
             # Protect against blank passwords in the DB
index d24597a..bc4b4c1 100644 (file)
@@ -5,10 +5,7 @@
 # Copyright (C) 2006 The Trustees of Princeton University
 #
 
-try:
-    from hashlib import md5
-except ImportError:
-    from md5 import md5
+from hashlib import md5
 import time
 from random import Random
 import re
@@ -113,8 +110,8 @@ class Person(Row):
         else:
             # Generate a somewhat unique 8 character salt string
             salt = str(time.time()) + str(Random().random())
-            salt = md5(salt).hexdigest()[:8]
-            return crypt.crypt(password.encode(self.api.encoding), magic + salt + "$")
+            salt = md5(salt.encode()).hexdigest()[:8]
+            return crypt.crypt(password, magic + salt + "$")
 
     validate_date_created = Row.validate_timestamp
     validate_last_updated = Row.validate_timestamp
index 9d565c4..f9f16bc 100644 (file)
@@ -68,7 +68,7 @@ class Site(Row):
         if not len(login_base):
             raise PLCInvalidArgument("Login base must be specified")
 
-        if not set(login_base).issubset(string.lowercase + string.digits + '.'):
+        if not set(login_base).issubset(string.ascii_lowercase + string.digits + '.'):
             raise PLCInvalidArgument("Login base must consist only of lowercase ASCII letters or numbers or dots")
 
         conflicts = Sites(self.api, [login_base])