FEATURE: better UI to manage 2fa (#19338)

In this PR, we introduced an option, that when all authenticators are disabled, but backup codes still exists, user can authenticate with those backup codes. This was reverted as this is not expected behavior.

https://github.com/discourse/discourse/pull/18982

Instead, when the last authenticator is deleted, backup codes should be deleted as well. Because this disables 2fa, user is asked to confirm that action by typing text.

In addition, UI for 2fa preferences was refreshed.
This commit is contained in:
Krzysztof Kotlarek
2022-12-08 09:41:22 +11:00
committed by GitHub
parent 63119144ff
commit e313190fdb
25 changed files with 297 additions and 152 deletions

View File

@@ -31,18 +31,6 @@ RSpec.describe AdminUserListSerializer do
end
end
context "when backup codes enabled" do
before do
Fabricate(:user_second_factor_backup, user: user)
end
it "is true" do
json = serializer.as_json
expect(json[:second_factor_enabled]).to eq(true)
end
end
describe "emails" do
fab!(:admin) { Fabricate(:user, admin: true, email: "admin@email.com") }
fab!(:moderator) { Fabricate(:user, moderator: true, email: "moderator@email.com") }

View File

@@ -102,16 +102,6 @@ RSpec.describe CurrentUserSerializer do
expect(json[:second_factor_enabled]).to eq(true)
end
end
context "when backup codes enabled" do
before do
User.any_instance.stubs(:backup_codes_enabled?).returns(true)
end
it "is true" do
expect(json[:second_factor_enabled]).to eq(true)
end
end
end
describe "#groups" do

View File

@@ -250,16 +250,6 @@ RSpec.describe UserSerializer do
expect(json[:second_factor_enabled]).to eq(true)
end
end
context "when backup codes enabled" do
before do
User.any_instance.stubs(:backup_codes_enabled?).returns(true)
end
it "is true" do
expect(json[:second_factor_enabled]).to eq(true)
end
end
end
describe "ignored and muted" do