Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/user.rb7
-rw-r--r--app/services/emails/create_service.rb4
2 files changed, 7 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 5e1355662b6..88dc5565a3a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -526,8 +526,11 @@ class User < ActiveRecord::Base
def update_emails_with_primary_email
primary_email_record = emails.find_by(email: email)
if primary_email_record
- Emails::DestroyService.new(self, email: email).execute
- Emails::CreateService.new(self, email: email_was).execute
+ Emails::DestroyService.new(self).execute(primary_email_record)
+
+ # the original primary email was confirmed, and we want that to carry over. We don't
+ # have access to the original confirmation values at this point, so just set confirmed_at
+ Emails::CreateService.new(self, email: email_was).execute(confirmed_at: confirmed_at_was)
end
end
diff --git a/app/services/emails/create_service.rb b/app/services/emails/create_service.rb
index b6491ee9804..051efd2b2c0 100644
--- a/app/services/emails/create_service.rb
+++ b/app/services/emails/create_service.rb
@@ -1,7 +1,7 @@
module Emails
class CreateService < ::Emails::BaseService
- def execute
- @user.emails.create(email: @email)
+ def execute(options = {})
+ @user.emails.create({email: @email}.merge(options))
end
end
end