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
e348f63b
Commit
e348f63b
authored
Sep 20, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor users update service into a EE module
parent
7367431d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
14 deletions
+32
-14
app/services/users/update_service.rb
app/services/users/update_service.rb
+2
-14
ee/app/services/ee/users/update_service.rb
ee/app/services/ee/users/update_service.rb
+30
-0
No files found.
app/services/users/update_service.rb
View file @
e348f63b
module
Users
class
UpdateService
<
BaseService
include
EE
::
Audit
::
Changes
include
NewUserNotifier
prepend
EE
::
Users
::
UpdateService
def
initialize
(
current_user
,
user
,
params
=
{})
@current_user
=
current_user
def
initialize
(
user
,
params
=
{})
@user
=
user
@params
=
params
.
dup
end
...
...
@@ -17,9 +16,6 @@ module Users
user_exists
=
@user
.
persisted?
if
@user
.
save
(
validate:
validate
)
audit_changes
(
:email
,
as:
'email address'
)
audit_changes
(
:encrypted_password
,
as:
'password'
,
skip_changes:
true
)
notify_new_user
(
@user
,
nil
)
unless
user_exists
success
...
...
@@ -39,15 +35,7 @@ module Users
private
def
assign_attributes
(
&
block
)
if
@user
.
user_synced_attributes_metadata
params
.
except!
(
*
@user
.
user_synced_attributes_metadata
.
read_only_attributes
)
end
@user
.
assign_attributes
(
params
)
if
params
.
any?
end
def
model
@user
end
end
end
ee/app/services/ee/users/update_service.rb
0 → 100644
View file @
e348f63b
module
EE
module
Users
module
UpdateService
include
EE
::
Audit
::
Changes
def
initialize
(
current_user
,
user
,
params
=
{})
@current_user
=
current_user
super
(
user
,
params
)
end
def
execute
(
*
args
,
&
block
)
result
=
super
(
*
args
,
&
block
)
if
result
[
:status
]
==
:success
audit_changes
(
:email
,
as:
'email address'
)
audit_changes
(
:encrypted_password
,
as:
'password'
,
skip_changes:
true
)
end
result
end
private
def
model
@user
end
end
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