Skip to content
Snippets Groups Projects
Commit 831b2fcc authored by James Lopez's avatar James Lopez
Browse files

update missing email actions

parent 87bf08c9
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -98,7 +98,7 @@ module API
authenticated_as_admin!
 
params = declared_params(include_missing: false)
user = ::Users::CreateService.new(current_user, params).execute
user = ::Users::CreateService.new(current_user, params).execute(skip_authorization: true)
 
if user.persisted?
present user, with: Entities::UserPublic
Loading
Loading
@@ -236,9 +236,7 @@ module API
user = User.find_by(id: params.delete(:id))
not_found!('User') unless user
 
email = user.emails.new(declared_params(include_missing: false))
if email.save
if Emails::CreateService.new(current_user, user, declared_params(include_missing: false)).execute(skip_authorization: true)
NotificationService.new.new_email(email)
present email, with: Entities::Email
else
Loading
Loading
@@ -276,7 +274,7 @@ module API
email = user.emails.find_by(id: params[:email_id])
not_found!('Email') unless email
 
Emails::DestroyService.new(current_user, user, email: email.email).execute
Emails::DestroyService.new(current_user, user, email: email.email).execute(skip_authorization: true)
 
::Users::UpdateService.new(current_user, user).execute do |user|
user.update_secondary_emails!
Loading
Loading
@@ -494,7 +492,7 @@ module API
post "emails" do
email = current_user.emails.new(declared_params)
 
if email.save
if Emails::CreateService.new(current_user, current_user, declared_params).execute
NotificationService.new.new_email(email)
present email, with: Entities::Email
else
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment