|
@@ -1,5 +1,6 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
import uuid
|
|
3
|
+import random
|
3
|
4
|
|
4
|
5
|
import pytz
|
5
|
6
|
from tracim import model as pm
|
|
@@ -7,6 +8,7 @@ from tracim import model as pm
|
7
|
8
|
from sprox.tablebase import TableBase
|
8
|
9
|
from sprox.formbase import EditableForm, AddRecordForm
|
9
|
10
|
from sprox.fillerbase import TableFiller, EditFormFiller
|
|
11
|
+from tracim.config.app_cfg import CFG
|
10
|
12
|
from tw2 import forms as tw2f
|
11
|
13
|
import tg
|
12
|
14
|
from tg import predicates
|
|
@@ -273,6 +275,11 @@ class UserRestController(TIMRestController):
|
273
|
275
|
profile = UserProfileAdminRestController()
|
274
|
276
|
workspaces = UserWorkspaceRestController()
|
275
|
277
|
|
|
278
|
+ PASSWORD_LENGTH = 12
|
|
279
|
+ PASSWORD_CHARACTERS = '0123456789' \
|
|
280
|
+ 'abcdefghijklmonpqrstuvwxyz' \
|
|
281
|
+ 'ABCDEFGHIJKLMONPQRSTUVWXYZ'
|
|
282
|
+
|
276
|
283
|
@classmethod
|
277
|
284
|
def current_item_id_key_in_context(cls):
|
278
|
285
|
return 'user_id'
|
|
@@ -326,7 +333,7 @@ class UserRestController(TIMRestController):
|
326
|
333
|
user.password = password
|
327
|
334
|
elif send_email:
|
328
|
335
|
# Setup a random password to send email at user
|
329
|
|
- password = str(uuid.uuid4())
|
|
336
|
+ password = self.generate_password()
|
330
|
337
|
user.password = password
|
331
|
338
|
|
332
|
339
|
user.webdav_left_digest_response_hash = '%s:/:%s' % (email, password)
|
|
@@ -351,6 +358,23 @@ class UserRestController(TIMRestController):
|
351
|
358
|
tg.flash(_('User {} created.').format(user.get_display_name()), CST.STATUS_OK)
|
352
|
359
|
tg.redirect(self.url())
|
353
|
360
|
|
|
361
|
+ @classmethod
|
|
362
|
+ def generate_password(
|
|
363
|
+ cls,
|
|
364
|
+ password_length = PASSWORD_LENGTH,
|
|
365
|
+ password_chars = PASSWORD_CHARACTERS
|
|
366
|
+ ):
|
|
367
|
+
|
|
368
|
+ # character list that will be contained into the password
|
|
369
|
+ char_list = []
|
|
370
|
+
|
|
371
|
+ for j in range(0, password_length):
|
|
372
|
+ # This puts a random char from the list above inside
|
|
373
|
+ # the list of chars and then merges them into a String
|
|
374
|
+ char_list.append(random.choice(password_chars))
|
|
375
|
+ password = ''.join(char_list)
|
|
376
|
+ return password
|
|
377
|
+
|
354
|
378
|
@tg.expose('tracim.templates.admin.user_getone')
|
355
|
379
|
def get_one(self, user_id):
|
356
|
380
|
current_user = tmpl_context.current_user
|