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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
01378ab4
Commit
01378ab4
authored
Jun 14, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update profiles controller to use new service
parent
59c3968c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
app/controllers/profiles_controller.rb
app/controllers/profiles_controller.rb
+18
-10
app/services/users/update_service.rb
app/services/users/update_service.rb
+3
-3
No files found.
app/controllers/profiles_controller.rb
View file @
01378ab4
...
...
@@ -12,39 +12,47 @@ class ProfilesController < Profiles::ApplicationController
user_params
.
except!
(
:email
)
if
@user
.
external_email?
respond_to
do
|
format
|
if
@user
.
update_attributes
(
user_params
)
status
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
user_params
).
execute
if
status
[
:success
]
message
=
"Profile was successfully updated"
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
notice:
message
})
}
format
.
json
{
render
json:
{
message:
message
}
}
else
message
=
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
alert:
"Failed to update profile.
#{
message
}
"
})
}
format
.
json
{
render
json:
{
message:
message
},
status: :unprocessable_entity
}
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
alert:
status
[
:message
]
})
}
format
.
json
{
render
json:
status
}
end
end
end
def
reset_private_token
if
current_user
.
reset_authentication_token!
flash
[
:notice
]
=
"Private token was successfully reset"
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute!
(
skip_authorization:
true
)
do
|
user
|
user
.
reset_authentication_token!
end
flash
[
:notice
]
=
"Private token was successfully reset"
redirect_to
profile_account_path
end
def
reset_incoming_email_token
if
current_user
.
reset_incoming_email_token!
flash
[
:notice
]
=
"Incoming email token was successfully reset"
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute!
(
skip_authorization:
true
)
do
|
user
|
user
.
reset_incoming_email_token!
end
flash
[
:notice
]
=
"Incoming email token was successfully reset"
redirect_to
profile_account_path
end
def
reset_rss_token
if
current_user
.
reset_rss_token!
flash
[
:notice
]
=
"RSS token was successfully reset"
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute!
(
skip_authorization:
true
)
do
|
user
|
user
.
reset_rss_token!
end
flash
[
:notice
]
=
"RSS token was successfully reset"
redirect_to
profile_account_path
end
...
...
app/services/users/update_service.rb
View file @
01378ab4
...
...
@@ -10,17 +10,17 @@ module Users
def
execute
(
skip_authorization:
false
,
&
block
)
assign_attributes
(
skip_authorization
,
&
block
)
if
@user
.
save
if
@user
.
save
||
!
@user
.
changed?
success
else
error
(
'User could not be updated'
)
error
(
"User could not be updated
#{
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
}
"
)
end
end
def
execute!
(
skip_authorization:
false
,
&
block
)
assign_attributes
(
skip_authorization
,
&
block
)
@user
.
save!
@user
.
save!
if
@user
.
changed?
end
private
...
...
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