From 7ddb7ff4290600f5bcb64ec230ee36197fb56880 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Fri, 4 Mar 2016 01:12:41 +0530 Subject: [PATCH] code optimization --- .../discourse/controllers/create-account.js.es6 | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6 index 33efac1000f..5b0864df783 100644 --- a/app/assets/javascripts/discourse/controllers/create-account.js.es6 +++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6 @@ -72,7 +72,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }.property('authOptions.auth_provider'), passwordInstructions: function() { - return this.get('isDeveloper') ? I18n.t('user.password.instructions', {count: Discourse.SiteSettings.min_admin_password_length}) : I18n.t('user.password.instructions', {count: Discourse.SiteSettings.min_password_length}); + return this.get('isDeveloper') ? I18n.t('user.password.instructions', {count: this.siteSettings.min_admin_password_length}) : I18n.t('user.password.instructions', {count: this.siteSettings.min_password_length}); }.property('isDeveloper'), nameInstructions: function() { @@ -284,16 +284,9 @@ export default Ember.Controller.extend(ModalFunctionality, { return Discourse.InputValidation.create({ failed: true }); } - // If too short for Admin - if (this.get('isDeveloper') && password.length < Discourse.SiteSettings.min_admin_password_length) { - return Discourse.InputValidation.create({ - failed: true, - reason: I18n.t('user.password.too_short') - }); - } - - // If too short for normal user - if (!this.get('isDeveloper') && password.length < Discourse.SiteSettings.min_password_length) { + // If too short + const passwordLength = this.get('isDeveloper') ? this.siteSettings.min_admin_password_length : this.siteSettings.min_password_length; + if (password.length < passwordLength) { return Discourse.InputValidation.create({ failed: true, reason: I18n.t('user.password.too_short')