diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 index e421f3bb..bd8408b2 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 @@ -82,9 +82,18 @@ export default Component.extend({ const controller = getOwner(this).lookup('controller:admin-wizard'); let content = controller[`${activeType}s`]; + // you can't select the current field in the field context if (activeType === 'wizardField' && this.options.context === 'field') { - const currentField = controller.currentField; - content = content.filter(field => field.id !== currentField.id); + content = content.filter(field => field.id !== controller.currentField.id); + } + + // updating usernames or emails via actions is not supported + if (activeType === 'userField' && + this.options.context === 'action' && + this.inputType === 'association' && + this.selectorType === 'key') { + + content = content.filter(userField => ['username','email'].indexOf(userField.id) === -1); } return content; diff --git a/assets/javascripts/discourse/lib/wizard.js.es6 b/assets/javascripts/discourse/lib/wizard.js.es6 index 7905e4c7..7734c450 100644 --- a/assets/javascripts/discourse/lib/wizard.js.es6 +++ b/assets/javascripts/discourse/lib/wizard.js.es6 @@ -32,6 +32,7 @@ function camelCase(string) { const userProperties = [ 'name', + 'username', 'email', 'avatar', 'date_of_birth', diff --git a/lib/custom_wizard/actions.rb b/lib/custom_wizard/actions.rb index 1bdec074..2fce945c 100644 --- a/lib/custom_wizard/actions.rb +++ b/lib/custom_wizard/actions.rb @@ -274,8 +274,12 @@ class CustomWizard::Action end end + def profile_excluded_fields + ['username', 'email'].freeze + end + def allowed_profile_fields - CustomWizard::Mapper.user_fields + + CustomWizard::Mapper.user_fields.select { |f| profile_excluded_fields.exclude?(f) } + profile_url_fields + ['avatar'] end diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index 697f9e6d..43573102 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -1,7 +1,7 @@ class CustomWizard::Mapper attr_accessor :inputs, :data, :user - USER_FIELDS = ['name', 'email', 'date_of_birth', 'title', 'locale', 'trust_level'] + USER_FIELDS = ['name', 'username', 'email', 'date_of_birth', 'title', 'locale', 'trust_level'] PROFILE_FIELDS = ['location', 'website', 'bio_raw'] def self.user_fields