diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-08-09 16:24:49 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-08-09 16:24:49 +0000 |
commit | 255be6c5ca805446ad29d8f45b3ef7ca9b11e23f (patch) | |
tree | 6409c560b9f429c59e86813c90e24b6452a92c9d /app | |
parent | a0fa59f61e28837265f30cd35f265d9311df3f7a (diff) | |
download | gitlab-ce-255be6c5ca805446ad29d8f45b3ef7ca9b11e23f.tar.gz |
Prevent user from changing username with container registry tags
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 5d8672d60b3..7935b89662b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -148,6 +148,8 @@ class User < ActiveRecord::Base uniqueness: { case_sensitive: false } validate :namespace_uniq, if: :username_changed? + validate :namespace_move_dir_allowed, if: :username_changed? + validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? } validate :unique_email, if: :email_changed? validate :owns_notification_email, if: :notification_email_changed? @@ -487,6 +489,12 @@ class User < ActiveRecord::Base end end + def namespace_move_dir_allowed + if namespace&.any_project_has_container_registry_tags? + errors.add(:username, 'cannot be changed if a personal project has container registry tags.') + end + end + def avatar_type unless avatar.image? errors.add :avatar, "only images allowed" |