enable 2FA for manager

when trying to access manager, if superadmin did'nt enable otp, he/she is redirected to a page to enable 2FA. When superadmin is enabling 2FA, he has to to scan a qrcode with the 2FA application client. And afterwards, the superadmin has to log in with email, password and OTP code.
This commit is contained in:
Christophe Robillard 2020-11-04 16:35:15 +01:00
parent 3fdb045356
commit 2a0ebd062a
14 changed files with 141 additions and 20 deletions

View file

@ -34,4 +34,31 @@ describe Administration, type: :model do
end
end
end
describe 'enable_otp!' do
let(:administration) { create(:administration, otp_required_for_login: false) }
let(:subject) { administration.enable_otp! }
it 'updates otp_required_for_login' do
expect { subject }.to change { administration.otp_required_for_login? }.from(false).to(true)
end
it 'updates otp_secret' do
expect { subject }.to change { administration.otp_secret }
end
end
describe 'disable_otp!' do
let(:administration) { create(:administration, otp_required_for_login: true) }
let(:subject) { administration.disable_otp! }
it 'updates otp_required_for_login' do
expect { subject }.to change { administration.otp_required_for_login? }.from(true).to(false)
end
it 'nullifies otp_secret' do
administration.enable_otp!
expect { subject }.to change { administration.reload.otp_secret }.to(nil)
end
end
end