FIX: Admin user list not showing 2FA icon for only security keys enabled (#8839)
If someone only had security keys enabled, the icon to say they had 2FA enabled would not show in the admin staff user list. It would only show if they had TOTP enabled.
This commit is contained in:
parent
9a199be279
commit
dd3a7f4825
|
@ -109,7 +109,7 @@ class AdminUserListSerializer < BasicUserSerializer
|
|||
def include_second_factor_enabled?
|
||||
!SiteSetting.enable_sso &&
|
||||
SiteSetting.enable_local_logins &&
|
||||
object.totps.present?
|
||||
object.has_any_second_factor_methods_enabled?
|
||||
end
|
||||
|
||||
def second_factor_enabled
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe AdminUserListSerializer do
|
||||
fab!(:user) { Fabricate(:user_second_factor_totp).user }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
let(:guardian) { Guardian.new(admin) }
|
||||
|
||||
|
@ -11,11 +11,27 @@ describe AdminUserListSerializer do
|
|||
AdminUserListSerializer.new(user, scope: guardian, root: false)
|
||||
end
|
||||
|
||||
it "returns the right values when user has second factor totp enabled" do
|
||||
context "when totp enabled" do
|
||||
before do
|
||||
Fabricate(:user_second_factor_totp, user: user)
|
||||
end
|
||||
it "returns the right values" do
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:second_factor_enabled]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "when security keys enabled" do
|
||||
before do
|
||||
Fabricate(:user_security_key, user: user)
|
||||
end
|
||||
it "returns the right values" do
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:second_factor_enabled]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "emails" do
|
||||
fab!(:admin) { Fabricate(:user, admin: true, email: "admin@email.com") }
|
||||
|
|
Loading…
Reference in New Issue