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
Léo-Paul Géneau
gitlab-ce
Commits
1c14805f
Commit
1c14805f
authored
Jun 14, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor profiles controller and update service
parent
01378ab4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
app/controllers/profiles_controller.rb
app/controllers/profiles_controller.rb
+11
-10
app/services/users/update_service.rb
app/services/users/update_service.rb
+1
-1
No files found.
app/controllers/profiles_controller.rb
View file @
1c14805f
...
...
@@ -12,16 +12,16 @@ class ProfilesController < Profiles::ApplicationController
user_params
.
except!
(
:email
)
if
@user
.
external_email?
respond_to
do
|
format
|
status
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
user_params
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
user_params
).
execute
if
status
[
:success
]
if
result
[
: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
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
alert:
status
[
:message
]
})
}
format
.
json
{
render
json:
status
}
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
alert:
result
[
:message
]
})
}
format
.
json
{
render
json:
result
}
end
end
end
...
...
@@ -63,12 +63,13 @@ class ProfilesController < Profiles::ApplicationController
end
def
update_username
if
@user
.
update_attributes
(
username:
user_params
[
:username
])
options
=
{
notice:
"Username successfully changed"
}
else
message
=
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
options
=
{
alert:
"Username change failed -
#{
message
}
"
}
end
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
username:
user_params
[
:username
]).
execute
options
=
if
result
[
:success
]
{
notice:
"Username successfully changed"
}
else
{
alert:
"Username change failed -
#{
result
[
:message
]
}
"
}
end
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
options
)
end
...
...
app/services/users/update_service.rb
View file @
1c14805f
...
...
@@ -13,7 +13,7 @@ module Users
if
@user
.
save
||
!
@user
.
changed?
success
else
error
(
"User could not be updated
#{
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
}
"
)
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
)
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