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
aa158dd7
Commit
aa158dd7
authored
Jun 15, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish off refactoring users controller
parent
85b5a8cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+25
-10
No files found.
app/controllers/admin/users_controller.rb
View file @
aa158dd7
...
...
@@ -54,7 +54,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def
block
if
u
ser
.
block
if
u
pdate_user
{
|
user
|
user
.
block
}
redirect_back_or_admin_user
(
notice:
"Successfully blocked"
)
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not blocked"
)
...
...
@@ -64,7 +64,7 @@ class Admin::UsersController < Admin::ApplicationController
def
unblock
if
user
.
ldap_blocked?
redirect_back_or_admin_user
(
alert:
"This user cannot be unlocked manually from GitLab"
)
elsif
u
ser
.
activate
elsif
u
pdate_user
{
|
user
|
user
.
activate
}
redirect_back_or_admin_user
(
notice:
"Successfully unblocked"
)
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unblocked"
)
...
...
@@ -72,7 +72,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def
unlock
if
u
ser
.
unlock_access!
if
u
pdate_user
{
|
user
|
user
.
unlock_access!
}
redirect_back_or_admin_user
(
alert:
"Successfully unlocked"
)
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unlocked"
)
...
...
@@ -80,7 +80,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def
confirm
if
u
ser
.
confirm
if
u
pdate_user
{
|
user
|
user
.
confirm
}
redirect_back_or_admin_user
(
notice:
"Successfully confirmed"
)
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not confirmed"
)
...
...
@@ -88,7 +88,8 @@ class Admin::UsersController < Admin::ApplicationController
end
def
disable_two_factor
user
.
disable_two_factor!
update_user
{
|
user
|
user
.
disable_two_factor!
}
redirect_to
admin_user_path
(
user
),
notice:
'Two-factor Authentication has been disabled for this user'
end
...
...
@@ -126,9 +127,9 @@ class Admin::UsersController < Admin::ApplicationController
respond_to
do
|
format
|
user
.
skip_reconfirmation!
result
=
Users
::
UpdateService
.
new
(
current_user
,
@
user
,
user_params_with_pass
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
user
,
user_params_with_pass
).
execute
if
result
[
:s
ucccess
]
if
result
[
:s
tatus
]
==
:success
format
.
html
{
redirect_to
[
:admin
,
user
],
notice:
'User was successfully updated.'
}
format
.
json
{
head
:ok
}
else
...
...
@@ -153,11 +154,17 @@ class Admin::UsersController < Admin::ApplicationController
email
=
user
.
emails
.
find
(
params
[
:email_id
])
email
.
destroy
user
.
update_secondary_emails!
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute
do
user
.
update_secondary_emails!
end
respond_to
do
|
format
|
if
result
[
:status
]
==
:success
format
.
html
{
redirect_back_or_admin_user
(
notice:
"Successfully removed email."
)
}
format
.
js
{
head
:ok
}
format
.
json
{
head
:ok
}
else
# restore username to keep form action url.
format
.
html
{
redirect_back_or_admin_user
(
notice:
result
[
:message
])
}
format
.
json
{
render
json:
result
[
:message
],
status:
result
[
:status
]
}
end
end
...
...
@@ -205,4 +212,12 @@ class Admin::UsersController < Admin::ApplicationController
:website_url
]
end
def
update_user
result
=
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
yield
(
user
)
end
result
[
:status
]
==
:success
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