mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
FEATURE: User fields required for existing users - Part 2 (#27172)
We want to allow admins to make new required fields apply to existing users. In order for this to work we need to have a way to make those users fill up the fields on their next page load. This is very similar to how adding a 2FA requirement post-fact works. Users will be redirected to a page where they can fill up the remaining required fields, and until they do that they won't be able to do anything else.
This commit is contained in:
@ -1843,6 +1843,21 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def populated_required_custom_fields?
|
||||
UserField
|
||||
.required
|
||||
.pluck(:id)
|
||||
.all? { |field_id| custom_fields["#{User::USER_FIELD_PREFIX}#{field_id}"].present? }
|
||||
end
|
||||
|
||||
def needs_required_fields_check?
|
||||
(required_fields_version || 0) < UserRequiredFieldsVersion.current
|
||||
end
|
||||
|
||||
def bump_required_fields_version
|
||||
update(required_fields_version: UserRequiredFieldsVersion.current)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def badge_grant
|
||||
@ -2225,6 +2240,7 @@ end
|
||||
# flair_group_id :integer
|
||||
# last_seen_reviewable_id :integer
|
||||
# password_algorithm :string(64)
|
||||
# required_fields_version :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
Reference in New Issue
Block a user