summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/profiles/emails_controller.rb2
-rw-r--r--app/models/user.rb2
-rw-r--r--app/services/emails/create_service.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb
index 9159c217f1b..40b43278439 100644
--- a/app/controllers/profiles/emails_controller.rb
+++ b/app/controllers/profiles/emails_controller.rb
@@ -7,7 +7,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
def create
@email = current_user.emails.new(email_params)
- if @email.save
+ if Emails::CreateService.new(current_user, current_user, email_params).execute
NotificationService.new.new_email(@email)
else
flash[:alert] = @email.errors.full_messages.first
diff --git a/app/models/user.rb b/app/models/user.rb
index bc754768ab1..6ca78278db8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -495,7 +495,7 @@ class User < ActiveRecord::Base
primary_email_record = emails.find_by(email: email)
if primary_email_record
Emails::DestroyService.new(self, self, email: email).execute
- emails.create(email: email_was)
+ Emails::CreateService.new(self, self, email: email_was).execute
update_secondary_emails!
end
diff --git a/app/services/emails/create_service.rb b/app/services/emails/create_service.rb
index 95e226ec710..ea65b82e418 100644
--- a/app/services/emails/create_service.rb
+++ b/app/services/emails/create_service.rb
@@ -3,7 +3,7 @@ module Emails
def execute(skip_authorization: false)
raise Gitlab::Access::AccessDeniedError unless skip_authorization || can_manage_emails?
- @user.emails.create!(email: @email)
+ @user.emails.create(email: @email)
end
end
end