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
ba7e2fd9
Commit
ba7e2fd9
authored
Mar 27, 2015
by
Dmitriy Zaporozhets
Committed by
Robert Speicher
May 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Two-factor authentication resource for user
parent
73023951
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
0 deletions
+48
-0
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+22
-0
app/views/profiles/accounts/show.html.haml
app/views/profiles/accounts/show.html.haml
+7
-0
app/views/profiles/two_factor_auths/new.html.haml
app/views/profiles/two_factor_auths/new.html.haml
+18
-0
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/controllers/profiles/two_factor_auths_controller.rb
0 → 100644
View file @
ba7e2fd9
class
Profiles::TwoFactorAuthsController
<
ApplicationController
def
new
issuer
=
"GitLab |
#{
current_user
.
email
}
"
uri
=
current_user
.
otp_provisioning_uri
(
current_user
.
email
,
issuer:
issuer
)
@qr_code
=
RQRCode
::
render_qrcode
(
uri
,
:svg
,
level: :l
,
unit:
2
)
end
def
create
current_user
.
otp_required_for_login
=
true
current_user
.
otp_secret
=
User
.
generate_otp_secret
current_user
.
save!
redirect_to
profile_account_path
end
def
destroy
current_user
.
otp_required_for_login
=
false
current_user
.
save!
redirect_to
profile_account_path
end
end
app/views/profiles/accounts/show.html.haml
View file @
ba7e2fd9
...
...
@@ -26,6 +26,13 @@
%span
You don`t have one yet. Click generate to fix it.
=
f
.
submit
'Generate'
,
class:
"btn success btn-build-token"
%fieldset
%legend
Two-Factor Authentication
%p
Keep your account secure by enabling two-factor authentication.
Each time you log in, you’ll be required to provide your password plus a randomly generated access code.
%div
=
link_to
"Enable 2-Factor Authentication"
,
new_profile_two_factor_auth_path
,
class:
'btn btn-success'
-
if
show_profile_social_tab?
%fieldset
...
...
app/views/profiles/two_factor_auths/new.html.haml
0 → 100644
View file @
ba7e2fd9
%h2
.page-title
Two-Factor Authentication (TFA)
%p
Download the Google Authenticator application from App Store for iOS or
Google Play for Android and scan this code.
%hr
=
form_tag
new_profile_two_factor_auth_path
,
method: :post
,
class:
'form-horizontal'
do
|
f
|
.form-group
.col-sm-2
.col-sm-10
=
raw
@qr_code
.form-group
=
label_tag
:pin_code
,
nil
,
class:
"control-label"
.col-sm-10
=
text_field_tag
:pin_code
,
nil
,
class:
"form-control"
,
required:
true
.form-actions
=
submit_tag
'Submit'
,
class:
'btn btn-success'
config/routes.rb
View file @
ba7e2fd9
...
...
@@ -226,6 +226,7 @@ Gitlab::Application.routes.draw do
resources
:keys
resources
:emails
,
only:
[
:index
,
:create
,
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
resource
:two_factor_auth
,
only:
[
:new
,
:create
,
:destroy
]
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