Parcourir la source

Fix reset password process

Bastien Sevajol (Algoo) il y a 8 ans
Parent
révision
b1151c30d5

+ 1 - 1
install/requirements.txt Voir le fichier

@@ -45,7 +45,7 @@ tw2.forms==2.2.2.1
45 45
 waitress==0.8.9
46 46
 zope.interface==4.1.3
47 47
 zope.sqlalchemy==0.7.6
48
-tgapp-resetpassword==0.1.3
48
+git+https://github.com/algoo/tgapp-resetpassword.git@master
49 49
 lxml
50 50
 python-ldap-test==0.2.0
51 51
 who-ldap==3.1.0

+ 1 - 0
tracim/tracim/config/app_cfg.py Voir le fichier

@@ -69,6 +69,7 @@ base_config['flash.template'] = '''
69 69
 # flash.js_call -> javascript code which will be run when displaying the flash from javascript. Default is webflash.render(), you can use webflash.payload() to retrieve the message and show it with your favourite library.
70 70
 # flash.js_template -> string.Template instance used to replace full javascript support for flash messages. When rendering flash message for javascript usage the following code will be used instead of providing the standard webflash object. If you replace js_template you must also ensure cookie parsing and delete it for already displayed messages. The template will receive: $container_id, $cookie_name, $js_call variables.
71 71
 
72
+base_config['templating.genshi.name_constant_patch'] = True
72 73
 
73 74
 # Configure the authentication backend
74 75
 

+ 5 - 0
tracim/tracim/controllers/root.py Voir le fichier

@@ -24,6 +24,7 @@ from tracim.controllers.error import ErrorController
24 24
 from tracim.controllers.help import HelpController
25 25
 from tracim.controllers.user import UserRestController
26 26
 from tracim.controllers.workspace import UserWorkspaceRestController
27
+from tracim.lib.utils import replace_reset_password_templates
27 28
 
28 29
 from tracim.model.data import ContentType
29 30
 from tracim.model.serializers import DictLikeClass
@@ -55,6 +56,10 @@ class RootController(StandardController):
55 56
     workspaces = UserWorkspaceRestController()
56 57
     user = UserRestController()
57 58
 
59
+    def _render_response(self, tgl, controller, response):
60
+        replace_reset_password_templates(controller.decoration.engines)
61
+        return super()._render_response(tgl, controller, response)
62
+
58 63
     def _before(self, *args, **kw):
59 64
         super(RootController, self)._before(args, kw)
60 65
         tmpl_context.project_name = "tracim"

+ 22 - 1
tracim/tracim/lib/utils.py Voir le fichier

@@ -17,4 +17,25 @@ def exec_time_monitor():
17 17
 
18 18
 
19 19
 class SameValueError(ValueError):
20
-    pass
20
+    pass
21
+
22
+
23
+def replace_reset_password_templates(engines):
24
+    try:
25
+        if engines['text/html'][1] == 'resetpassword.templates.index':
26
+            engines['text/html'] = (
27
+                'mako',
28
+                'tracim.templates.reset_password_index',
29
+                engines['text/html'][2],
30
+                engines['text/html'][3]
31
+            )
32
+
33
+        if engines['text/html'][1] == 'resetpassword.templates.change_password':
34
+            engines['text/html'] = (
35
+                'mako',
36
+                'tracim.templates.reset_password_change_password',
37
+                engines['text/html'][2],
38
+                engines['text/html'][3]
39
+            )
40
+    except IndexError:
41
+        pass