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
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
...
@@ -12,16 +12,16 @@ class ProfilesController < Profiles::ApplicationController
user_params
.
except!
(
:email
)
if
@user
.
external_email?
user_params
.
except!
(
:email
)
if
@user
.
external_email?
respond_to
do
|
format
|
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"
message
=
"Profile was successfully updated"
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
notice:
message
})
}
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
notice:
message
})
}
format
.
json
{
render
json:
{
message:
message
}
}
format
.
json
{
render
json:
{
message:
message
}
}
else
else
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
alert:
status
[
:message
]
})
}
format
.
html
{
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
{
alert:
result
[
:message
]
})
}
format
.
json
{
render
json:
status
}
format
.
json
{
render
json:
result
}
end
end
end
end
end
end
...
@@ -63,12 +63,13 @@ class ProfilesController < Profiles::ApplicationController
...
@@ -63,12 +63,13 @@ class ProfilesController < Profiles::ApplicationController
end
end
def
update_username
def
update_username
if
@user
.
update_attributes
(
username:
user_params
[
:username
])
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
username:
user_params
[
:username
]).
execute
options
=
{
notice:
"Username successfully changed"
}
else
options
=
if
result
[
:success
]
message
=
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
{
notice:
"Username successfully changed"
}
options
=
{
alert:
"Username change failed -
#{
message
}
"
}
else
end
{
alert:
"Username change failed -
#{
result
[
:message
]
}
"
}
end
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
options
)
redirect_back_or_default
(
default:
{
action:
'show'
},
options:
options
)
end
end
...
...
app/services/users/update_service.rb
View file @
1c14805f
...
@@ -13,7 +13,7 @@ module Users
...
@@ -13,7 +13,7 @@ module Users
if
@user
.
save
||
!
@user
.
changed?
if
@user
.
save
||
!
@user
.
changed?
success
success
else
else
error
(
"User could not be updated
#{
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
}
"
)
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
)
)
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