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
Jérome Perrin
gitlab-ce
Commits
800df45d
Commit
800df45d
authored
Jul 10, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add disable_two_factor route for Admin::Users
parent
22724418
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+6
-0
config/routes.rb
config/routes.rb
+1
-0
spec/controllers/admin/users_controller_spec.rb
spec/controllers/admin/users_controller_spec.rb
+28
-0
No files found.
app/controllers/admin/users_controller.rb
View file @
800df45d
...
...
@@ -55,6 +55,12 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
disable_two_factor
user
.
disable_two_factor!
redirect_to
admin_user_path
(
user
),
notice:
'Two-factor Authentication has been disabled for this user'
end
def
create
opts
=
{
force_random_password:
true
,
...
...
config/routes.rb
View file @
800df45d
...
...
@@ -159,6 +159,7 @@ Gitlab::Application.routes.draw do
put
:block
put
:unblock
put
:unlock
patch
:disable_two_factor
delete
'remove/:email_id'
,
action:
'remove_email'
,
as:
'remove_email'
end
end
...
...
spec/controllers/admin/users_controller_spec.rb
View file @
800df45d
...
...
@@ -36,4 +36,32 @@ describe Admin::UsersController do
expect
(
user
.
access_locked?
).
to
be_falsey
end
end
describe
'PATCH disable_two_factor'
do
let
(
:user
)
{
create
(
:user
)
}
it
'disables 2FA for the user'
do
expect
(
user
).
to
receive
(
:disable_two_factor!
)
allow
(
subject
).
to
receive
(
:user
).
and_return
(
user
)
go
end
it
'redirects back'
do
go
expect
(
response
).
to
redirect_to
(
admin_user_path
(
user
))
end
it
'displays an alert'
do
go
expect
(
flash
[
:notice
]).
to
eq
'Two-factor Authentication has been disabled for this user'
end
def
go
patch
:disable_two_factor
,
id:
user
.
to_param
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