summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-23 21:22:00 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-06-23 21:22:00 -0400
commit7e4829c3e94fa3bdeee50d0b96785f0aa833829e (patch)
tree86e514c254dfe28b94d8cb2ba4cb403e87bd77d0
parent764b5913c8f960d09d4777e3233662f507b0ec13 (diff)
downloadgitlab-ce-7e4829c3e94fa3bdeee50d0b96785f0aa833829e.tar.gz
Allow user to remove public email addressrs-dev-issue-2419
-rw-r--r--app/models/user.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 22cd15bf971..f1bcecc13b3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -351,6 +351,8 @@ class User < ActiveRecord::Base
end
def owns_public_email
+ return if self.public_email.blank?
+
self.errors.add(:public_email, "is not an email you own") unless self.all_emails.include?(self.public_email)
end
@@ -531,7 +533,7 @@ class User < ActiveRecord::Base
def set_public_email
if self.public_email.blank? || !self.all_emails.include?(self.public_email)
- self.public_email = nil
+ self.public_email = ''
end
end