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
831b2fcc
Commit
831b2fcc
authored
Jun 19, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update missing email actions
parent
87bf08c9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
9 deletions
+7
-9
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/create_service.rb
app/services/emails/create_service.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+4
-6
No files found.
app/controllers/profiles/emails_controller.rb
View file @
831b2fcc
...
@@ -7,7 +7,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
...
@@ -7,7 +7,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
def
create
def
create
@email
=
current_user
.
emails
.
new
(
email_params
)
@email
=
current_user
.
emails
.
new
(
email_params
)
if
@email
.
sav
e
if
Emails
::
CreateService
.
new
(
current_user
,
current_user
,
email_params
).
execut
e
NotificationService
.
new
.
new_email
(
@email
)
NotificationService
.
new
.
new_email
(
@email
)
else
else
flash
[
:alert
]
=
@email
.
errors
.
full_messages
.
first
flash
[
:alert
]
=
@email
.
errors
.
full_messages
.
first
...
...
app/models/user.rb
View file @
831b2fcc
...
@@ -495,7 +495,7 @@ class User < ActiveRecord::Base
...
@@ -495,7 +495,7 @@ class User < ActiveRecord::Base
primary_email_record
=
emails
.
find_by
(
email:
email
)
primary_email_record
=
emails
.
find_by
(
email:
email
)
if
primary_email_record
if
primary_email_record
Emails
::
DestroyService
.
new
(
self
,
self
,
email:
email
).
execute
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!
update_secondary_emails!
end
end
...
...
app/services/emails/create_service.rb
View file @
831b2fcc
...
@@ -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?
@user
.
emails
.
create
!
(
email:
@email
)
@user
.
emails
.
create
(
email:
@email
)
end
end
end
end
end
end
lib/api/users.rb
View file @
831b2fcc
...
@@ -98,7 +98,7 @@ module API
...
@@ -98,7 +98,7 @@ module API
authenticated_as_admin!
authenticated_as_admin!
params
=
declared_params
(
include_missing:
false
)
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?
if
user
.
persisted?
present
user
,
with:
Entities
::
UserPublic
present
user
,
with:
Entities
::
UserPublic
...
@@ -236,9 +236,7 @@ module API
...
@@ -236,9 +236,7 @@ module API
user
=
User
.
find_by
(
id:
params
.
delete
(
:id
))
user
=
User
.
find_by
(
id:
params
.
delete
(
:id
))
not_found!
(
'User'
)
unless
user
not_found!
(
'User'
)
unless
user
email
=
user
.
emails
.
new
(
declared_params
(
include_missing:
false
))
if
Emails
::
CreateService
.
new
(
current_user
,
user
,
declared_params
(
include_missing:
false
)).
execute
(
skip_authorization:
true
)
if
email
.
save
NotificationService
.
new
.
new_email
(
email
)
NotificationService
.
new
.
new_email
(
email
)
present
email
,
with:
Entities
::
Email
present
email
,
with:
Entities
::
Email
else
else
...
@@ -276,7 +274,7 @@ module API
...
@@ -276,7 +274,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
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
|
::
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
user
.
update_secondary_emails!
user
.
update_secondary_emails!
...
@@ -494,7 +492,7 @@ module API
...
@@ -494,7 +492,7 @@ module API
post
"emails"
do
post
"emails"
do
email
=
current_user
.
emails
.
new
(
declared_params
)
email
=
current_user
.
emails
.
new
(
declared_params
)
if
email
.
sav
e
if
Emails
::
CreateService
.
new
(
current_user
,
current_user
,
declared_params
).
execut
e
NotificationService
.
new
.
new_email
(
email
)
NotificationService
.
new
.
new_email
(
email
)
present
email
,
with:
Entities
::
Email
present
email
,
with:
Entities
::
Email
else
else
...
...
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