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
iv
gitlab-ce
Commits
ba9855d4
Commit
ba9855d4
authored
Dec 29, 2015
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent ldap_blocked users from being unblocked by the Admin UI
parent
bc7ef8e5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
11 deletions
+38
-11
app/assets/stylesheets/framework/buttons.scss
app/assets/stylesheets/framework/buttons.scss
+3
-0
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+3
-1
app/views/admin/users/index.html.haml
app/views/admin/users/index.html.haml
+6
-1
spec/controllers/admin/users_controller_spec.rb
spec/controllers/admin/users_controller_spec.rb
+26
-9
No files found.
app/assets/stylesheets/framework/buttons.scss
View file @
ba9855d4
...
...
@@ -132,6 +132,9 @@
margin-right
:
0px
;
}
}
&
.disabled
{
pointer-events
:
auto
!
important
;
}
}
.btn-block
{
...
...
app/controllers/admin/users_controller.rb
View file @
ba9855d4
...
...
@@ -40,7 +40,9 @@ class Admin::UsersController < Admin::ApplicationController
end
def
unblock
if
user
.
activate
if
user
.
ldap_blocked?
redirect_back_or_admin_user
(
alert:
"This user cannot be unlocked manually from GitLab"
)
elsif
user
.
activate
redirect_back_or_admin_user
(
notice:
"Successfully unblocked"
)
else
redirect_back_or_admin_user
(
alert:
"Error occurred. User was not unblocked"
)
...
...
app/views/admin/users/index.html.haml
View file @
ba9855d4
...
...
@@ -90,7 +90,12 @@
=
link_to
'Edit'
,
edit_admin_user_path
(
user
),
id:
"edit_
#{
dom_id
(
user
)
}
"
,
class:
"btn btn-xs"
-
unless
user
==
current_user
-
if
user
.
blocked?
-
if
user
.
ldap_blocked?
=
link_to
'#'
,
title:
'Cannot unblock LDAP blocked users'
,
data:
{
toggle:
'tooltip'
},
class:
'btn btn-xs btn-success disabled'
do
%i
.fa.fa-lock
Unblock
=
''
-
elsif
user
.
blocked?
=
link_to
'Unblock'
,
unblock_admin_user_path
(
user
),
method: :put
,
class:
"btn btn-xs btn-success"
-
else
=
link_to
'Block'
,
block_admin_user_path
(
user
),
data:
{
confirm:
'USER WILL BE BLOCKED! Are you sure?'
},
method: :put
,
class:
"btn btn-xs btn-warning"
...
...
spec/controllers/admin/users_controller_spec.rb
View file @
ba9855d4
...
...
@@ -34,17 +34,34 @@ describe Admin::UsersController do
end
describe
'PUT unblock/:id'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
user
.
block
context
'ldap blocked users'
do
let
(
:user
)
{
create
(
:omniauth_user
,
provider:
'ldapmain'
)
}
before
do
user
.
ldap_block
end
it
'will not unblock user'
do
put
:unblock
,
id:
user
.
username
user
.
reload
expect
(
user
.
blocked?
).
to
be_truthy
expect
(
flash
[
:alert
]).
to
eq
'This user cannot be unlocked manually from GitLab'
end
end
it
'unblocks user'
do
put
:unblock
,
id:
user
.
username
user
.
reload
expect
(
user
.
blocked?
).
to
be_falsey
expect
(
flash
[
:notice
]).
to
eq
'Successfully unblocked'
context
'manually blocked users'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
user
.
block
end
it
'unblocks user'
do
put
:unblock
,
id:
user
.
username
user
.
reload
expect
(
user
.
blocked?
).
to
be_falsey
expect
(
flash
[
:notice
]).
to
eq
'Successfully unblocked'
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