Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
1735ed61
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,发现更多精彩内容 >>
提交
1735ed61
编写于
3月 14, 2017
作者:
A
Alexis Reigel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename cache db column with `_cached` suffix
上级
20575859
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
12 addition
and
12 deletion
+12
-12
app/controllers/concerns/enforces_two_factor_authentication.rb
...ontrollers/concerns/enforces_two_factor_authentication.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-1
db/migrate/20170124193205_add_two_factor_columns_to_users.rb
db/migrate/20170124193205_add_two_factor_columns_to_users.rb
+2
-2
db/schema.rb
db/schema.rb
+1
-1
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+2
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+4
-4
未找到文件。
app/controllers/concerns/enforces_two_factor_authentication.rb
浏览文件 @
1735ed61
...
...
@@ -21,7 +21,7 @@ module EnforcesTwoFactorAuthentication
def
two_factor_authentication_required?
current_application_settings
.
require_two_factor_authentication?
||
current_user
.
try
(
:require_two_factor_authentication?
)
current_user
.
try
(
:require_two_factor_authentication
_from_group
?
)
end
def
two_factor_authentication_reason
(
global:
->
{},
group:
->
{})
...
...
@@ -37,7 +37,7 @@ module EnforcesTwoFactorAuthentication
def
two_factor_grace_period
periods
=
[
current_application_settings
.
two_factor_grace_period
]
periods
<<
current_user
.
two_factor_grace_period
if
current_user
.
try
(
:require_two_factor_authentication?
)
periods
<<
current_user
.
two_factor_grace_period
if
current_user
.
try
(
:require_two_factor_authentication
_from_group
?
)
periods
.
min
end
...
...
app/models/user.rb
浏览文件 @
1735ed61
...
...
@@ -974,7 +974,7 @@ class User < ActiveRecord::Base
def
update_two_factor_requirement
periods
=
expanded_groups_requiring_two_factor_authentication
.
pluck
(
:two_factor_grace_period
)
self
.
require_two_factor_authentication
=
periods
.
any?
self
.
require_two_factor_authentication
_from_group
=
periods
.
any?
self
.
two_factor_grace_period
=
periods
.
min
||
User
.
column_defaults
[
'two_factor_grace_period'
]
save
...
...
db/migrate/20170124193205_add_two_factor_columns_to_users.rb
浏览文件 @
1735ed61
...
...
@@ -6,12 +6,12 @@ class AddTwoFactorColumnsToUsers < ActiveRecord::Migration
disable_ddl_transaction!
def
up
add_column_with_default
(
:users
,
:require_two_factor_authentication
,
:boolean
,
default:
false
)
add_column_with_default
(
:users
,
:require_two_factor_authentication
_from_group
,
:boolean
,
default:
false
)
add_column_with_default
(
:users
,
:two_factor_grace_period
,
:integer
,
default:
48
)
end
def
down
remove_column
(
:users
,
:require_two_factor_authentication
)
remove_column
(
:users
,
:require_two_factor_authentication
_from_group
)
remove_column
(
:users
,
:two_factor_grace_period
)
end
end
db/schema.rb
浏览文件 @
1735ed61
...
...
@@ -1249,7 +1249,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
boolean
"authorized_projects_populated"
t
.
boolean
"ghost"
t
.
boolean
"notified_of_own_activity"
t
.
boolean
"require_two_factor_authentication"
,
default:
false
,
null:
false
t
.
boolean
"require_two_factor_authentication
_from_group
"
,
default:
false
,
null:
false
t
.
integer
"two_factor_grace_period"
,
default:
48
,
null:
false
end
...
...
spec/controllers/application_controller_spec.rb
浏览文件 @
1735ed61
...
...
@@ -183,7 +183,7 @@ describe ApplicationController do
end
it
'returns true if a 2FA requirement is set on the user'
do
user
.
require_two_factor_authentication
=
true
user
.
require_two_factor_authentication
_from_group
=
true
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
expect
(
subject
).
to
be_truthy
...
...
@@ -201,7 +201,7 @@ describe ApplicationController do
end
context
'with a 2FA requirement set on the user'
do
let
(
:user
)
{
create
:user
,
require_two_factor_authentication:
true
,
two_factor_grace_period:
23
}
let
(
:user
)
{
create
:user
,
require_two_factor_authentication
_from_group
:
true
,
two_factor_grace_period:
23
}
it
'returns the user grace period if lower than the application grace period'
do
stub_application_setting
two_factor_grace_period:
24
...
...
spec/models/user_spec.rb
浏览文件 @
1735ed61
...
...
@@ -1548,7 +1548,7 @@ describe User, models: true do
end
it
'requires 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
true
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
true
end
it
'uses the shortest grace period'
do
...
...
@@ -1567,7 +1567,7 @@ describe User, models: true do
end
it
'requires 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
true
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
true
end
end
...
...
@@ -1582,7 +1582,7 @@ describe User, models: true do
end
it
'requires 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
true
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
true
end
end
...
...
@@ -1596,7 +1596,7 @@ describe User, models: true do
end
it
'does not require 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
false
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
false
end
it
'falls back to the default grace period'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录