Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
fa3aa0c5
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,发现更多精彩内容 >>
提交
fa3aa0c5
编写于
5月 22, 2019
作者:
K
Kartikey Tanna
提交者:
James Lopez
5月 22, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#61441 Allow user to set email ID before setting up 2FA
上级
6d495d65
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
4 deletion
+24
-4
app/controllers/concerns/enforces_two_factor_authentication.rb
...ontrollers/concerns/enforces_two_factor_authentication.rb
+1
-1
changelogs/unreleased/61441.yml
changelogs/unreleased/61441.yml
+5
-0
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+18
-3
未找到文件。
app/controllers/concerns/enforces_two_factor_authentication.rb
浏览文件 @
fa3aa0c5
...
@@ -16,7 +16,7 @@ module EnforcesTwoFactorAuthentication
...
@@ -16,7 +16,7 @@ module EnforcesTwoFactorAuthentication
end
end
def
check_two_factor_requirement
def
check_two_factor_requirement
if
two_factor_authentication_required?
&&
current_user
&&
!
current_user
.
two_factor_enabled?
&&
!
skip_two_factor?
if
two_factor_authentication_required?
&&
current_user
&&
!
current_user
.
t
emp_oauth_email?
&&
!
current_user
.
t
wo_factor_enabled?
&&
!
skip_two_factor?
redirect_to
profile_two_factor_auth_path
redirect_to
profile_two_factor_auth_path
end
end
end
end
...
...
changelogs/unreleased/61441.yml
0 → 100644
浏览文件 @
fa3aa0c5
---
title
:
Allow user to set primary email first when 2FA is required
merge_request
:
28097
author
:
Kartikey Tanna
type
:
fixed
spec/controllers/application_controller_spec.rb
浏览文件 @
fa3aa0c5
...
@@ -206,8 +206,19 @@ describe ApplicationController do
...
@@ -206,8 +206,19 @@ describe ApplicationController do
describe
'#check_two_factor_requirement'
do
describe
'#check_two_factor_requirement'
do
subject
{
controller
.
send
:check_two_factor_requirement
}
subject
{
controller
.
send
:check_two_factor_requirement
}
it
'does not redirect if user has temporary oauth email'
do
oauth_user
=
create
(
:user
,
email:
'temp-email-for-oauth@email.com'
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
oauth_user
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
subject
end
it
'does not redirect if 2FA is not required'
do
it
'does not redirect if 2FA is not required'
do
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
false
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
false
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
subject
subject
...
@@ -216,6 +227,7 @@ describe ApplicationController do
...
@@ -216,6 +227,7 @@ describe ApplicationController do
it
'does not redirect if user is not logged in'
do
it
'does not redirect if user is not logged in'
do
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
nil
)
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
nil
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
subject
subject
...
@@ -223,8 +235,9 @@ describe ApplicationController do
...
@@ -223,8 +235,9 @@ describe ApplicationController do
it
'does not redirect if user has 2FA enabled'
do
it
'does not redirect if user has 2FA enabled'
do
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:current_user
).
t
w
ice
.
and_return
(
user
)
allow
(
controller
).
to
receive
(
:current_user
).
t
hr
ice
.
and_return
(
user
)
allow
(
user
).
to
receive
(
:two_factor_enabled?
).
and_return
(
true
)
allow
(
user
).
to
receive
(
:two_factor_enabled?
).
and_return
(
true
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
subject
subject
...
@@ -232,9 +245,10 @@ describe ApplicationController do
...
@@ -232,9 +245,10 @@ describe ApplicationController do
it
'does not redirect if 2FA setup can be skipped'
do
it
'does not redirect if 2FA setup can be skipped'
do
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:current_user
).
t
w
ice
.
and_return
(
user
)
allow
(
controller
).
to
receive
(
:current_user
).
t
hr
ice
.
and_return
(
user
)
allow
(
user
).
to
receive
(
:two_factor_enabled?
).
and_return
(
false
)
allow
(
user
).
to
receive
(
:two_factor_enabled?
).
and_return
(
false
)
allow
(
controller
).
to
receive
(
:skip_two_factor?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:skip_two_factor?
).
and_return
(
true
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
expect
(
controller
).
not_to
receive
(
:redirect_to
)
subject
subject
...
@@ -242,10 +256,11 @@ describe ApplicationController do
...
@@ -242,10 +256,11 @@ describe ApplicationController do
it
'redirects to 2FA setup otherwise'
do
it
'redirects to 2FA setup otherwise'
do
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
true
)
allow
(
controller
).
to
receive
(
:current_user
).
t
w
ice
.
and_return
(
user
)
allow
(
controller
).
to
receive
(
:current_user
).
t
hr
ice
.
and_return
(
user
)
allow
(
user
).
to
receive
(
:two_factor_enabled?
).
and_return
(
false
)
allow
(
user
).
to
receive
(
:two_factor_enabled?
).
and_return
(
false
)
allow
(
controller
).
to
receive
(
:skip_two_factor?
).
and_return
(
false
)
allow
(
controller
).
to
receive
(
:skip_two_factor?
).
and_return
(
false
)
allow
(
controller
).
to
receive
(
:profile_two_factor_auth_path
)
allow
(
controller
).
to
receive
(
:profile_two_factor_auth_path
)
expect
(
controller
).
to
receive
(
:redirect_to
)
expect
(
controller
).
to
receive
(
:redirect_to
)
subject
subject
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录