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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8ae712ae
Commit
8ae712ae
authored
Apr 02, 2015
by
Dmitriy Zaporozhets
Committed by
Robert Speicher
May 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render 2fa recovery codes instead of downloading it
parent
802fcd05
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
12 deletions
+28
-12
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+3
-3
app/views/profiles/accounts/show.html.haml
app/views/profiles/accounts/show.html.haml
+5
-8
app/views/profiles/two_factor_auths/_codes.html.haml
app/views/profiles/two_factor_auths/_codes.html.haml
+12
-0
app/views/profiles/two_factor_auths/codes.html.haml
app/views/profiles/two_factor_auths/codes.html.haml
+3
-0
app/views/profiles/two_factor_auths/create.html.haml
app/views/profiles/two_factor_auths/create.html.haml
+4
-0
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/profiles/two_factor_auths_controller.rb
View file @
8ae712ae
...
@@ -11,9 +11,10 @@ class Profiles::TwoFactorAuthsController < ApplicationController
...
@@ -11,9 +11,10 @@ class Profiles::TwoFactorAuthsController < ApplicationController
def
create
def
create
if
current_user
.
valid_otp?
(
params
[
:pin_code
])
if
current_user
.
valid_otp?
(
params
[
:pin_code
])
current_user
.
otp_required_for_login
=
true
current_user
.
otp_required_for_login
=
true
@codes
=
current_user
.
generate_otp_backup_codes!
current_user
.
save!
current_user
.
save!
re
direct_to
profile_account_path
re
nder
'create'
else
else
@error
=
'Invalid pin code'
@error
=
'Invalid pin code'
@qr_code
=
build_qr_code
@qr_code
=
build_qr_code
...
@@ -22,9 +23,8 @@ class Profiles::TwoFactorAuthsController < ApplicationController
...
@@ -22,9 +23,8 @@ class Profiles::TwoFactorAuthsController < ApplicationController
end
end
def
codes
def
codes
codes
=
current_user
.
generate_otp_backup_codes!
@
codes
=
current_user
.
generate_otp_backup_codes!
current_user
.
save!
current_user
.
save!
send_data
codes
.
join
(
"
\n
"
),
filename:
'gitlab_recovery_codes.txt'
end
end
def
destroy
def
destroy
...
...
app/views/profiles/accounts/show.html.haml
View file @
8ae712ae
...
@@ -35,14 +35,11 @@
...
@@ -35,14 +35,11 @@
%div
%div
.pull-right
.pull-right
=
link_to
"Disable 2-Factor Authentication"
,
profile_two_factor_auth_path
,
method: :delete
,
class:
'btn btn-close btn-sm'
=
link_to
"Disable 2-Factor Authentication"
,
profile_two_factor_auth_path
,
method: :delete
,
class:
'btn btn-close btn-sm'
%p
.slead
%p
%i
.fa.fa-warning
If you lost your recovery codes - you can
Please
%strong
%strong
#{
link_to
"download recovery codes"
,
codes_profile_two_factor_auth_path
}
=
link_to
"generate new one"
,
codes_profile_two_factor_auth_path
,
method: :post
,
so you can access your account if you lose your phone.
data:
{
confirm:
'After we generate new recovery codes - old codes will not be valid any more. Are you sure?'
}
%br
%i
.fa.fa-warning
Every time you download recovery codes - we generate the new codes. Previously downloaded codes won't work anymore.
-
else
-
else
%legend
Two-Factor Authentication
%legend
Two-Factor Authentication
...
...
app/views/profiles/two_factor_auths/_codes.html.haml
0 → 100644
View file @
8ae712ae
%p
.slead
Please save this recovery codes so you can access your account if you lose your phone.
.codes.well
%ul
-
@codes
.
each
do
|
code
|
%li
%span
.monospace
=
code
=
link_to
profile_account_path
,
class:
'btn btn-success'
do
I saved the codes
app/views/profiles/two_factor_auths/codes.html.haml
0 → 100644
View file @
8ae712ae
%h3
.page-title
Two-Factor Authentication Recovery codes
%hr
=
render
'codes'
app/views/profiles/two_factor_auths/create.html.haml
0 → 100644
View file @
8ae712ae
.alert.alert-success
Congratulations! You have enabled Two-Factor Authentication!
=
render
'codes'
config/routes.rb
View file @
8ae712ae
...
@@ -228,7 +228,7 @@ Gitlab::Application.routes.draw do
...
@@ -228,7 +228,7 @@ Gitlab::Application.routes.draw do
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
resource
:two_factor_auth
,
only:
[
:new
,
:create
,
:destroy
]
do
resource
:two_factor_auth
,
only:
[
:new
,
:create
,
:destroy
]
do
member
do
member
do
ge
t
:codes
pos
t
:codes
end
end
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