diff --git a/app/assets/javascripts/discourse/controllers/preferences_username_controller.js.coffee b/app/assets/javascripts/discourse/controllers/preferences_username_controller.js.coffee index 4bc2bd97bc8..38dde021dab 100644 --- a/app/assets/javascripts/discourse/controllers/preferences_username_controller.js.coffee +++ b/app/assets/javascripts/discourse/controllers/preferences_username_controller.js.coffee @@ -1,18 +1,18 @@ Discourse.PreferencesUsernameController = Ember.ObjectController.extend Discourse.Presence, taken: false - invalid: false saving: false error: false + errorMessage: null saveDisabled: (-> return true if @get('saving') return true if @blank('newUsername') return true if @get('taken') - return true if @get('invalid') return true if @get('unchanged') + return true if @get('errorMessage') false - ).property('newUsername', 'taken', 'invalid', 'unchanged', 'saving') + ).property('newUsername', 'taken', 'errorMessage', 'unchanged', 'saving') unchanged: (-> @get('newUsername') == @get('content.username') @@ -20,12 +20,12 @@ Discourse.PreferencesUsernameController = Ember.ObjectController.extend Discours checkTaken: (-> @set('taken', false) - @set('invalid', false) + @set('errorMessage', null) return if @blank('newUsername') return if @get('unchanged') Discourse.User.checkUsername(@get('newUsername')).then (result) => if result.errors - @set('invalid', true) + @set('errorMessage', result.errors.join(' ')) else if result.available == false @set('taken', true) ).observes('newUsername') diff --git a/app/assets/javascripts/discourse/templates/user/username.js.handlebars b/app/assets/javascripts/discourse/templates/user/username.js.handlebars index 97c5b934b7e..7b4676102fe 100644 --- a/app/assets/javascripts/discourse/templates/user/username.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/username.js.handlebars @@ -23,9 +23,7 @@ {{#if controller.taken}} {{i18n user.change_username.taken}} {{/if}} - {{#if controller.invalid}} - {{i18n user.change_username.invalid}} - {{/if}} + {{ errorMessage }}