FEATURE: add site setting to include user associated account ids. (#18375)

By default, we won't include associated account ids in current user serializer. If the new hidden site setting `include_associated_account_ids` is enabled then we will add it in the serializer.
This commit is contained in:
Vinoth Kannan
2022-09-27 12:40:20 +05:30
committed by GitHub
parent 7152345ee7
commit 0b6c89dc62
3 changed files with 33 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ class CurrentUserSerializer < BasicUserSerializer
:can_create_group,
:link_posting_access,
:external_id,
:associated_account_ids,
:top_category_ids,
:hide_profile_and_presence,
:groups,
@@ -293,6 +294,20 @@ class CurrentUserSerializer < BasicUserSerializer
SiteSetting.enable_discourse_connect
end
def associated_account_ids
values = {}
object.user_associated_accounts.map do |user_associated_account|
values[user_associated_account.provider_name] = user_associated_account.provider_uid
end
values
end
def include_associated_account_ids?
SiteSetting.include_associated_account_ids
end
def second_factor_enabled
object.totp_enabled? || object.security_keys_enabled?
end