BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
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
...
@@ -54,7 +54,7 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
block
def
block
if
u
ser
.
block
if
u
pdate_user
{
|
user
|
user
.
block
}
redirect_back_or_admin_user
(
notice:
"Successfully blocked"
)
redirect_back_or_admin_user
(
notice:
"Successfully blocked"
)
else
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not blocked"
)
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not blocked"
)
...
@@ -64,7 +64,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -64,7 +64,7 @@ class Admin::UsersController < Admin::ApplicationController
def
unblock
def
unblock
if
user
.
ldap_blocked?
if
user
.
ldap_blocked?
redirect_back_or_admin_user
(
alert:
"This user cannot be unlocked manually from GitLab"
)
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"
)
redirect_back_or_admin_user
(
notice:
"Successfully unblocked"
)
else
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unblocked"
)
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unblocked"
)
...
@@ -72,7 +72,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -72,7 +72,7 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
unlock
def
unlock
if
u
ser
.
unlock_access!
if
u
pdate_user
{
|
user
|
user
.
unlock_access!
}
redirect_back_or_admin_user
(
alert:
"Successfully unlocked"
)
redirect_back_or_admin_user
(
alert:
"Successfully unlocked"
)
else
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unlocked"
)
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unlocked"
)
...
@@ -80,7 +80,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -80,7 +80,7 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
confirm
def
confirm
if
u
ser
.
confirm
if
u
pdate_user
{
|
user
|
user
.
confirm
}
redirect_back_or_admin_user
(
notice:
"Successfully confirmed"
)
redirect_back_or_admin_user
(
notice:
"Successfully confirmed"
)
else
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not confirmed"
)
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not confirmed"
)
...
@@ -88,7 +88,8 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -88,7 +88,8 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
disable_two_factor
def
disable_two_factor
user
.
disable_two_factor!
update_user
{
|
user
|
user
.
disable_two_factor!
}
redirect_to
admin_user_path
(
user
),
redirect_to
admin_user_path
(
user
),
notice:
'Two-factor Authentication has been disabled for this user'
notice:
'Two-factor Authentication has been disabled for this user'
end
end
...
@@ -126,9 +127,9 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -126,9 +127,9 @@ class Admin::UsersController < Admin::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
user
.
skip_reconfirmation!
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
.
html
{
redirect_to
[
:admin
,
user
],
notice:
'User was successfully updated.'
}
format
.
json
{
head
:ok
}
format
.
json
{
head
:ok
}
else
else
...
@@ -153,11 +154,17 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -153,11 +154,17 @@ class Admin::UsersController < Admin::ApplicationController
email
=
user
.
emails
.
find
(
params
[
:email_id
])
email
=
user
.
emails
.
find
(
params
[
:email_id
])
email
.
destroy
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
.
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
end
end
...
@@ -205,4 +212,12 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -205,4 +212,12 @@ class Admin::UsersController < Admin::ApplicationController
:website_url
:website_url
]
]
end
end
def
update_user
result
=
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
yield
(
user
)
end
result
[
:status
]
==
:success
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