Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3bab585b
Commit
3bab585b
authored
Jun 19, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update to use emails destroy service
parent
ad44af2f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
6 deletions
+7
-6
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-1
app/controllers/profiles/emails_controller.rb
app/controllers/profiles/emails_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/services/emails/destroy_service.rb
app/services/emails/destroy_service.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+3
-2
No files found.
app/controllers/admin/users_controller.rb
View file @
3bab585b
...
@@ -152,7 +152,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -152,7 +152,7 @@ class Admin::UsersController < Admin::ApplicationController
def
remove_email
def
remove_email
email
=
user
.
emails
.
find
(
params
[
:email_id
])
email
=
user
.
emails
.
find
(
params
[
:email_id
])
email
.
destroy
Emails
::
DestroyService
.
new
(
current_user
,
self
,
email:
email
.
email
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute
do
|
user
|
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute
do
|
user
|
user
.
update_secondary_emails!
user
.
update_secondary_emails!
...
...
app/controllers/profiles/emails_controller.rb
View file @
3bab585b
...
@@ -18,7 +18,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
...
@@ -18,7 +18,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
def
destroy
def
destroy
@email
=
current_user
.
emails
.
find
(
params
[
:id
])
@email
=
current_user
.
emails
.
find
(
params
[
:id
])
@email
.
destroy
Emails
::
DestroyService
.
new
(
self
,
self
,
email:
@email
.
email
).
execute
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute
{
|
user
|
user
.
update_secondary_emails!
}
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute
{
|
user
|
user
.
update_secondary_emails!
}
...
...
app/models/user.rb
View file @
3bab585b
...
@@ -494,7 +494,7 @@ class User < ActiveRecord::Base
...
@@ -494,7 +494,7 @@ class User < ActiveRecord::Base
def
update_emails_with_primary_email
def
update_emails_with_primary_email
primary_email_record
=
emails
.
find_by
(
email:
email
)
primary_email_record
=
emails
.
find_by
(
email:
email
)
if
primary_email_record
if
primary_email_record
primary_email_record
.
destroy
Emails
::
DestroyService
.
new
(
self
,
self
,
email:
email
).
execute
emails
.
create
(
email:
email_was
)
emails
.
create
(
email:
email_was
)
update_secondary_emails!
update_secondary_emails!
...
...
app/services/emails/destroy_service.rb
View file @
3bab585b
...
@@ -3,7 +3,7 @@ module Emails
...
@@ -3,7 +3,7 @@ module Emails
def
execute
(
skip_authorization:
false
)
def
execute
(
skip_authorization:
false
)
raise
Gitlab
::
Access
::
AccessDeniedError
unless
skip_authorization
||
can_manage_emails?
raise
Gitlab
::
Access
::
AccessDeniedError
unless
skip_authorization
||
can_manage_emails?
Email
.
find_by_email
(
@email
).
destroy
!
Email
.
find_by_email
(
@email
).
destroy
end
end
end
end
end
end
lib/api/users.rb
View file @
3bab585b
...
@@ -276,7 +276,7 @@ module API
...
@@ -276,7 +276,7 @@ module API
email
=
user
.
emails
.
find_by
(
id:
params
[
:email_id
])
email
=
user
.
emails
.
find_by
(
id:
params
[
:email_id
])
not_found!
(
'Email'
)
unless
email
not_found!
(
'Email'
)
unless
email
email
.
destroy
Emails
::
DestroyService
.
new
(
current_user
,
self
,
email:
email
.
email
).
execute
::
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
::
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
user
.
update_secondary_emails!
user
.
update_secondary_emails!
...
@@ -510,7 +510,8 @@ module API
...
@@ -510,7 +510,8 @@ module API
email
=
current_user
.
emails
.
find_by
(
id:
params
[
:email_id
])
email
=
current_user
.
emails
.
find_by
(
id:
params
[
:email_id
])
not_found!
(
'Email'
)
unless
email
not_found!
(
'Email'
)
unless
email
email
.
destroy
Emails
::
DestroyService
.
new
(
current_user
,
self
,
email:
email
.
email
).
execute
::
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute
do
|
user
|
::
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute
do
|
user
|
user
.
update_secondary_emails!
user
.
update_secondary_emails!
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment