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
Kazuhiko Shiozaki
gitlab-ce
Commits
eb9528b8
Commit
eb9528b8
authored
Sep 24, 2015
by
Pavel Forkert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move login button to user page, switched to POST method
parent
83347954
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
21 deletions
+27
-21
app/views/admin/users/_head.html.haml
app/views/admin/users/_head.html.haml
+2
-0
app/views/admin/users/index.html.haml
app/views/admin/users/index.html.haml
+0
-1
config/routes.rb
config/routes.rb
+1
-1
spec/controllers/admin/users_controller_spec.rb
spec/controllers/admin/users_controller_spec.rb
+3
-3
spec/features/admin/admin_users_spec.rb
spec/features/admin/admin_users_spec.rb
+21
-16
No files found.
app/views/admin/users/_head.html.haml
View file @
eb9528b8
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
%span
.cred
(Admin)
%span
.cred
(Admin)
.pull-right
.pull-right
-
unless
@user
==
current_user
=
link_to
'Log in as this user'
,
login_as_admin_user_path
(
@user
),
method: :post
,
class:
"btn btn-grouped btn-info"
=
link_to
edit_admin_user_path
(
@user
),
class:
"btn btn-grouped"
do
=
link_to
edit_admin_user_path
(
@user
),
class:
"btn btn-grouped"
do
%i
.fa.fa-pencil-square-o
%i
.fa.fa-pencil-square-o
Edit
Edit
...
...
app/views/admin/users/index.html.haml
View file @
eb9528b8
...
@@ -90,7 +90,6 @@
...
@@ -90,7 +90,6 @@
=
link_to
'Edit'
,
edit_admin_user_path
(
user
),
id:
"edit_
#{
dom_id
(
user
)
}
"
,
class:
"btn btn-xs"
=
link_to
'Edit'
,
edit_admin_user_path
(
user
),
id:
"edit_
#{
dom_id
(
user
)
}
"
,
class:
"btn btn-xs"
-
unless
user
==
current_user
-
unless
user
==
current_user
=
link_to
'Log in'
,
login_as_admin_user_path
(
user
),
method: :put
,
class:
"btn btn-xs btn-primary"
-
if
user
.
blocked?
-
if
user
.
blocked?
=
link_to
'Unblock'
,
unblock_admin_user_path
(
user
),
method: :put
,
class:
"btn btn-xs btn-success"
=
link_to
'Unblock'
,
unblock_admin_user_path
(
user
),
method: :put
,
class:
"btn btn-xs btn-success"
-
else
-
else
...
...
config/routes.rb
View file @
eb9528b8
...
@@ -262,7 +262,7 @@ Gitlab::Application.routes.draw do
...
@@ -262,7 +262,7 @@ Gitlab::Application.routes.draw do
put
:unblock
put
:unblock
put
:unlock
put
:unlock
put
:confirm
put
:confirm
p
u
t
:login_as
p
os
t
:login_as
patch
:disable_two_factor
patch
:disable_two_factor
delete
'remove/:email_id'
,
action:
'remove_email'
,
as:
'remove_email'
delete
'remove/:email_id'
,
action:
'remove_email'
,
as:
'remove_email'
end
end
...
...
spec/controllers/admin/users_controller_spec.rb
View file @
eb9528b8
...
@@ -7,17 +7,17 @@ describe Admin::UsersController do
...
@@ -7,17 +7,17 @@ describe Admin::UsersController do
sign_in
(
admin
)
sign_in
(
admin
)
end
end
describe
'P
U
T login_as'
do
describe
'P
OS
T login_as'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
it
'logs admin as another user'
do
it
'logs admin as another user'
do
expect
(
warden
.
authenticate
(
scope: :user
)).
not_to
eq
(
user
)
expect
(
warden
.
authenticate
(
scope: :user
)).
not_to
eq
(
user
)
p
u
t
:login_as
,
id:
user
.
username
p
os
t
:login_as
,
id:
user
.
username
expect
(
warden
.
authenticate
(
scope: :user
)).
to
eq
(
user
)
expect
(
warden
.
authenticate
(
scope: :user
)).
to
eq
(
user
)
end
end
it
'redirects user to homepage'
do
it
'redirects user to homepage'
do
p
u
t
:login_as
,
id:
user
.
username
p
os
t
:login_as
,
id:
user
.
username
expect
(
response
).
to
redirect_to
(
root_path
)
expect
(
response
).
to
redirect_to
(
root_path
)
end
end
end
end
...
...
spec/features/admin/admin_users_spec.rb
View file @
eb9528b8
...
@@ -111,6 +111,27 @@ describe "Admin::Users", feature: true do
...
@@ -111,6 +111,27 @@ describe "Admin::Users", feature: true do
expect
(
page
).
to
have_content
(
@user
.
name
)
expect
(
page
).
to
have_content
(
@user
.
name
)
end
end
describe
'Login as another user'
do
it
'should show login button for other users'
do
another_user
=
create
(
:user
)
visit
admin_user_path
(
another_user
)
click_link
'Log in as this user'
expect
(
page
).
to
have_content
(
"Logged in as
#{
another_user
.
username
}
"
)
page
.
within
'.sidebar-user .username'
do
expect
(
page
).
to
have_content
(
another_user
.
username
)
end
end
it
'should not show login button for admin itself'
do
visit
admin_user_path
(
@user
)
expect
(
page
).
not_to
have_content
(
'Log in as this user'
)
end
end
describe
'Two-factor Authentication status'
do
describe
'Two-factor Authentication status'
do
it
'shows when enabled'
do
it
'shows when enabled'
do
@user
.
update_attribute
(
:two_factor_enabled
,
true
)
@user
.
update_attribute
(
:two_factor_enabled
,
true
)
...
@@ -166,20 +187,4 @@ describe "Admin::Users", feature: true do
...
@@ -166,20 +187,4 @@ describe "Admin::Users", feature: true do
end
end
end
end
end
end
it
'should be able to log in as another user'
do
another_user
=
create
(
:user
)
visit
admin_users_path
page
.
within
".user-
#{
another_user
.
id
}
"
do
click_link
'Log in'
end
expect
(
page
).
to
have_content
(
"Logged in as
#{
another_user
.
username
}
"
)
page
.
within
'.sidebar-user .username'
do
expect
(
page
).
to
have_content
(
another_user
.
username
)
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