|
@@ -1,5 +1,6 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
import pytz
|
|
3
|
+from tracim.lib import CST
|
3
|
4
|
from webob.exc import HTTPForbidden
|
4
|
5
|
import tg
|
5
|
6
|
from tg import tmpl_context
|
|
@@ -168,7 +169,17 @@ class UserRestController(TIMRestController):
|
168
|
169
|
def put(self, user_id, name, email, timezone, next_url=None):
|
169
|
170
|
user_id = tmpl_context.current_user.user_id
|
170
|
171
|
current_user = tmpl_context.current_user
|
|
172
|
+ user_api = UserApi(current_user)
|
171
|
173
|
assert user_id==current_user.user_id
|
|
174
|
+ if next_url:
|
|
175
|
+ next = tg.url(next_url)
|
|
176
|
+ else:
|
|
177
|
+ next = self.url()
|
|
178
|
+
|
|
179
|
+ email_user = user_api.get_one_by_email(email)
|
|
180
|
+ if email_user != current_user:
|
|
181
|
+ tg.flash(_('Email already in use'), CST.STATUS_ERROR)
|
|
182
|
+ tg.redirect(next)
|
172
|
183
|
|
173
|
184
|
# Only keep allowed field update
|
174
|
185
|
updated_fields = self._clean_update_fields({
|
|
@@ -180,9 +191,7 @@ class UserRestController(TIMRestController):
|
180
|
191
|
api = UserApi(tmpl_context.current_user)
|
181
|
192
|
api.update(current_user, do_save=True, **updated_fields)
|
182
|
193
|
tg.flash(_('profile updated.'))
|
183
|
|
- if next_url:
|
184
|
|
- tg.redirect(tg.url(next_url))
|
185
|
|
- tg.redirect(self.url())
|
|
194
|
+ tg.redirect(next)
|
186
|
195
|
|
187
|
196
|
def _clean_update_fields(self, fields: dict):
|
188
|
197
|
"""
|