##// END OF EJS Templates
fix(user-models): added extra protection against model username changes that would create duplicates
super-admin -
r5352:77661e7b default
parent child Browse files
Show More
@@ -136,6 +136,7 b' class MyAccountView(BaseAppView, DataGri'
136 136 except forms.ValidationFailure as e:
137 137 c.form = e
138 138 return self._get_template_context(c)
139
139 140 except Exception:
140 141 log.exception("Exception updating user")
141 142 h.flash(_('Error occurred during update of user'),
@@ -144,6 +144,10 b' class NotAllowedToCreateUserError(Except'
144 144 pass
145 145
146 146
147 class DuplicateUpdateUserError(Exception):
148 pass
149
150
147 151 class RepositoryCreationError(Exception):
148 152 pass
149 153
@@ -37,7 +37,7 b' from rhodecode.lib.str_utils import safe'
37 37 from rhodecode.lib.exceptions import (
38 38 DefaultUserException, UserOwnsReposException, UserOwnsRepoGroupsException,
39 39 UserOwnsUserGroupsException, NotAllowedToCreateUserError,
40 UserOwnsPullRequestsException, UserOwnsArtifactsException)
40 UserOwnsPullRequestsException, UserOwnsArtifactsException, DuplicateUpdateUserError)
41 41 from rhodecode.lib.caching_query import FromCache
42 42 from rhodecode.model import BaseModel
43 43 from rhodecode.model.db import (
@@ -308,6 +308,10 b' class UserModel(BaseModel):'
308 308 log.debug('Checking for existing account in RhodeCode '
309 309 'database with user_id `%s` ', updating_user_id)
310 310 user = User.get(updating_user_id)
311 # now also validate if USERNAME belongs to potentially other user
312 maybe_other_user = User.get_by_username(username, case_insensitive=True)
313 if maybe_other_user and maybe_other_user.user_id != updating_user_id:
314 raise DuplicateUpdateUserError(f'different user exists with the {username} username')
311 315 else:
312 316 log.debug('Checking for existing account in RhodeCode '
313 317 'database with username `%s` ', username)
General Comments 0
You need to be logged in to leave comments. Login now