Show More
@@ -158,13 +158,18 b' class UsersController(BaseController):' | |||||
158 | # url('user', id=ID) |
|
158 | # url('user', id=ID) | |
159 | user_model = UserModel() |
|
159 | user_model = UserModel() | |
160 | c.user = user_model.get(id) |
|
160 | c.user = user_model.get(id) | |
|
161 | c.ldap_dn = c.user.ldap_dn | |||
161 | c.perm_user = AuthUser(user_id=id) |
|
162 | c.perm_user = AuthUser(user_id=id) | |
162 | _form = UserForm(edit=True, old_data={'user_id': id, |
|
163 | _form = UserForm(edit=True, old_data={'user_id': id, | |
163 | 'email': c.user.email})() |
|
164 | 'email': c.user.email})() | |
164 | form_result = {} |
|
165 | form_result = {} | |
165 | try: |
|
166 | try: | |
166 | form_result = _form.to_python(dict(request.POST)) |
|
167 | form_result = _form.to_python(dict(request.POST)) | |
167 | user_model.update(id, form_result) |
|
168 | skip_attrs = [] | |
|
169 | if c.ldap_dn: | |||
|
170 | #forbid updating username for ldap accounts | |||
|
171 | skip_attrs = ['username'] | |||
|
172 | user_model.update(id, form_result, skip_attrs=skip_attrs) | |||
168 | usr = form_result['username'] |
|
173 | usr = form_result['username'] | |
169 | action_logger(self.rhodecode_user, 'admin_updated_user:%s' % usr, |
|
174 | action_logger(self.rhodecode_user, 'admin_updated_user:%s' % usr, | |
170 | None, self.ip_addr, self.sa) |
|
175 | None, self.ip_addr, self.sa) | |
@@ -233,6 +238,7 b' class UsersController(BaseController):' | |||||
233 | c.user_email_map = UserEmailMap.query()\ |
|
238 | c.user_email_map = UserEmailMap.query()\ | |
234 | .filter(UserEmailMap.user == c.user).all() |
|
239 | .filter(UserEmailMap.user == c.user).all() | |
235 | user_model = UserModel() |
|
240 | user_model = UserModel() | |
|
241 | c.ldap_dn = c.user.ldap_dn | |||
236 | defaults = c.user.get_dict() |
|
242 | defaults = c.user.get_dict() | |
237 | defaults.update({ |
|
243 | defaults.update({ | |
238 | 'create_repo_perm': user_model.has_perm(id, 'hg.create.repository'), |
|
244 | 'create_repo_perm': user_model.has_perm(id, 'hg.create.repository'), |
@@ -246,7 +246,7 b' class UserModel(BaseModel):' | |||||
246 | log.error(traceback.format_exc()) |
|
246 | log.error(traceback.format_exc()) | |
247 | raise |
|
247 | raise | |
248 |
|
248 | |||
249 | def update(self, user_id, form_data): |
|
249 | def update(self, user_id, form_data, skip_attrs=[]): | |
250 | from rhodecode.lib.auth import get_crypt_password |
|
250 | from rhodecode.lib.auth import get_crypt_password | |
251 | try: |
|
251 | try: | |
252 | user = self.get(user_id, cache=False) |
|
252 | user = self.get(user_id, cache=False) | |
@@ -256,6 +256,8 b' class UserModel(BaseModel):' | |||||
256 | " crucial for entire application")) |
|
256 | " crucial for entire application")) | |
257 |
|
257 | |||
258 | for k, v in form_data.items(): |
|
258 | for k, v in form_data.items(): | |
|
259 | if k in skip_attrs: | |||
|
260 | continue | |||
259 | if k == 'new_password' and v: |
|
261 | if k == 'new_password' and v: | |
260 | user.password = get_crypt_password(v) |
|
262 | user.password = get_crypt_password(v) | |
261 | user.api_key = generate_api_key(user.username) |
|
263 | user.api_key = generate_api_key(user.username) |
@@ -50,7 +50,11 b'' | |||||
50 | <label for="username">${_('Username')}:</label> |
|
50 | <label for="username">${_('Username')}:</label> | |
51 | </div> |
|
51 | </div> | |
52 | <div class="input"> |
|
52 | <div class="input"> | |
53 | ${h.text('username',class_='medium')} |
|
53 | %if c.ldap_dn: | |
|
54 | ${h.text('username',class_='medium disabled', readonly="readonly")} | |||
|
55 | %else: | |||
|
56 | ${h.text('username',class_='medium')} | |||
|
57 | %endif: | |||
54 | </div> |
|
58 | </div> | |
55 | </div> |
|
59 | </div> | |
56 |
|
60 |
General Comments 0
You need to be logged in to leave comments.
Login now