Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/decorators/mfa_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def two_factor_configurations

def two_factor_enabled?
return true if phone_configurations.any?(&:mfa_enabled?)
return true if piv_cac_configurations.any?(&:mfa_enabled?)
return true if auth_app_configurations.any?(&:mfa_enabled?)
return true if backup_code_configurations.any?(&:mfa_enabled?)
return true if webauthn_configurations.any?(&:mfa_enabled?)
return true if backup_code_configurations.any?(&:mfa_enabled?)
return true if auth_app_configurations.any?(&:mfa_enabled?)
return true if piv_cac_configurations.any?(&:mfa_enabled?)
return false
end

Expand Down
16 changes: 16 additions & 0 deletions spec/decorators/mfa_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@
end
end

describe '#two_factor_enabled?' do
subject(:two_factor_enabled?) { mfa.two_factor_enabled? }

context 'when user has an associated mfa' do
let(:user) { create(:user, :with_phone) }

it { expect(two_factor_enabled?).to eq(true) }
end

context 'when user does not have any associated mfa' do
let(:user) { create(:user) }

it { expect(two_factor_enabled?).to eq(false) }
end
end

describe '#enabled_mfa_methods_count' do
context 'with 2 phones' do
it 'returns 2' do
Expand Down
14 changes: 0 additions & 14 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,6 @@
end
end

context '#two_factor_enabled?' do
it 'is true when user has a confirmed phone' do
user = create(:user, :with_phone)

expect(MfaPolicy.new(user).two_factor_enabled?).to eq true
end

it 'is false when user does not have a phone' do
user = create(:user)

expect(MfaPolicy.new(user).two_factor_enabled?).to eq false
end
end

describe '#fully_registered?' do
let(:user) { create(:user) }
subject(:fully_registered?) { user.fully_registered? }
Expand Down