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
ca559099
Commit
ca559099
authored
Sep 20, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor services
parent
ab603346
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
25 deletions
+19
-25
app/services/emails/base_service.rb
app/services/emails/base_service.rb
+2
-1
app/services/users/update_service.rb
app/services/users/update_service.rb
+11
-4
ee/app/services/ee/emails/base_service.rb
ee/app/services/ee/emails/base_service.rb
+0
-6
ee/app/services/ee/users/update_service.rb
ee/app/services/ee/users/update_service.rb
+6
-14
No files found.
app/services/emails/base_service.rb
View file @
ca559099
module
Emails
class
BaseService
def
initialize
(
user
,
opts
)
def
initialize
(
current_user
,
user
,
opts
)
@current_user
=
current_user
@user
=
user
@email
=
opts
[
:email
]
end
...
...
app/services/users/update_service.rb
View file @
ca559099
...
...
@@ -3,7 +3,8 @@ module Users
include
NewUserNotifier
prepend
EE
::
Users
::
UpdateService
def
initialize
(
user
,
params
=
{})
def
initialize
(
current_user
,
user
,
params
=
{})
@current_user
=
current_user
@user
=
user
@params
=
params
.
dup
end
...
...
@@ -16,9 +17,7 @@ module Users
user_exists
=
@user
.
persisted?
if
@user
.
save
(
validate:
validate
)
notify_new_user
(
@user
,
nil
)
unless
user_exists
success
notify_success
else
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
))
end
...
...
@@ -32,6 +31,14 @@ module Users
true
end
protected
def
notify_success
notify_new_user
(
@user
,
nil
)
unless
@user
.
persisted?
success
end
private
def
assign_attributes
(
&
block
)
...
...
ee/app/services/ee/emails/base_service.rb
View file @
ca559099
module
EE
module
Emails
module
BaseService
def
initialize
(
current_user
,
user
,
opts
)
@current_user
=
current_user
super
(
user
,
opts
)
end
private
def
log_audit_event
(
options
=
{})
...
...
ee/app/services/ee/users/update_service.rb
View file @
ca559099
...
...
@@ -3,25 +3,17 @@ module EE
module
UpdateService
include
EE
::
Audit
::
Changes
def
initialize
(
current_user
,
user
,
params
=
{})
@current_user
=
current_user
super
(
user
,
params
)
end
private
def
execute
(
*
args
,
&
block
)
result
=
super
(
*
args
,
&
block
)
def
notify_success
notify_new_user
(
@user
,
nil
)
unless
@user
.
persisted?
if
result
[
:status
]
==
:success
audit_changes
(
:email
,
as:
'email address'
)
audit_changes
(
:encrypted_password
,
as:
'password'
,
skip_changes:
true
)
end
audit_changes
(
:email
,
as:
'email address'
)
audit_changes
(
:encrypted_password
,
as:
'password'
,
skip_changes:
true
)
result
success
end
private
def
model
@user
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