Ver código fonte

password generator enhanced : @staticmethod -> @classmethod ; list turned into a String ; pep8 modifications

Alexis CLEMENT 8 anos atrás
pai
commit
d0d5ffb0ac

+ 2 - 1
tracim/tracim/config/app_cfg.py Ver arquivo

@@ -218,7 +218,8 @@ class CFG(object):
218 218
             )
219 219
 
220 220
         self.AUTO_GENERATED_PASSWORD_LENGTH = tg.config.get(
221
-            'tracim.password.length')
221
+            'tracim.password.length'
222
+        )
222 223
 
223 224
         self.EMAIL_NOTIFICATION_FROM_EMAIL = \
224 225
             tg.config.get('email.notification.from.email')

+ 6 - 12
tracim/tracim/controllers/admin/user.py Ver arquivo

@@ -328,7 +328,7 @@ class UserRestController(TIMRestController):
328 328
             user.password = password
329 329
         elif send_email:
330 330
             # Setup a random password to send email at user
331
-            password = UserRestController.generate_password()
331
+            password = self.generate_password()
332 332
             user.password = password
333 333
 
334 334
         user.webdav_left_digest_response_hash = '%s:/:%s' % (email, password)
@@ -353,18 +353,12 @@ class UserRestController(TIMRestController):
353 353
         tg.flash(_('User {} created.').format(user.get_display_name()), CST.STATUS_OK)
354 354
         tg.redirect(self.url())
355 355
 
356
-    @staticmethod
357
-    def generate_password():
356
+    @classmethod
357
+    def generate_password(cls):
358 358
         # Characters available to generate a password
359
-        characters = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
360
-
361
-                      'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
362
-                      'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
363
-                      'u', 'v', 'w', 'x', 'y', 'z',
364
-
365
-                      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
366
-                      'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
367
-                      'U', 'V', 'W', 'X', 'Y', 'Z']
359
+        characters = '0123456789' \
360
+                     'abcdefghijklmonpqrstuvwxyz' \
361
+                     'ABCDEFGHIJKLMONPQRSTUVWXYZ'
368 362
 
369 363
         # character list that will be contained into the password
370 364
         list_char = []