Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
cde474a4
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cde474a4
编写于
3月 27, 2015
作者:
D
Dmitriy Zaporozhets
提交者:
Robert Speicher
5月 09, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make 2 factor authentication work
上级
ba7e2fd9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
9 deletion
+37
-9
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+24
-7
app/views/profiles/accounts/show.html.haml
app/views/profiles/accounts/show.html.haml
+9
-1
app/views/profiles/two_factor_auths/new.html.haml
app/views/profiles/two_factor_auths/new.html.haml
+4
-1
未找到文件。
app/controllers/profiles/two_factor_auths_controller.rb
浏览文件 @
cde474a4
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
)
unless
current_user
.
otp_secret
current_user
.
otp_secret
=
User
.
generate_otp_secret
current_user
.
save!
end
@qr_code
=
build_qr_code
end
def
create
current_user
.
otp_required_for_login
=
true
current_user
.
otp_secret
=
User
.
generate_otp_secret
current_user
.
save!
if
current_user
.
valid_otp?
(
params
[
:pin_code
])
current_user
.
otp_required_for_login
=
true
#current_user.otp_secret = User.generate_otp_secret
current_user
.
save!
redirect_to
profile_account_path
redirect_to
profile_account_path
else
@error
=
'Invalid pin code'
@qr_code
=
build_qr_code
render
'new'
end
end
def
destroy
...
...
@@ -19,4 +28,12 @@ class Profiles::TwoFactorAuthsController < ApplicationController
redirect_to
profile_account_path
end
private
def
build_qr_code
issuer
=
"GitLab |
#{
current_user
.
email
}
"
uri
=
current_user
.
otp_provisioning_uri
(
current_user
.
email
,
issuer:
issuer
)
RQRCode
::
render_qrcode
(
uri
,
:svg
,
level: :m
,
unit:
3
)
end
end
app/views/profiles/accounts/show.html.haml
浏览文件 @
cde474a4
...
...
@@ -30,9 +30,17 @@
%legend
Two-Factor Authentication
%p
Keep your account secure by enabling two-factor authentication.
%br
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
current_user
.
otp_required_for_login
%strong
.text-success
%i
.fa.fa-check
2-Factor Authentication enabled
.pull-right
=
link_to
"Disable 2-Factor Authentication"
,
profile_two_factor_auth_path
,
method: :delete
,
class:
'btn btn-close btn-sm'
-
else
=
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
浏览文件 @
cde474a4
...
...
@@ -5,7 +5,10 @@
%hr
=
form_tag
new_profile_two_factor_auth_path
,
method: :post
,
class:
'form-horizontal'
do
|
f
|
=
form_tag
profile_two_factor_auth_path
,
method: :post
,
class:
'form-horizontal'
do
|
f
|
-
if
@error
.alert.alert-danger
=
@error
.form-group
.col-sm-2
.col-sm-10
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录