From 24d81e2364791a2b5d1ed12b8e504627315a4fa1 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 17 Dec 2013 12:37:49 -0500 Subject: [PATCH] FIX: deprecation warning in create_account_controller.js. Need to move createAccount into actions. --- .../controllers/create_account_controller.js | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/create_account_controller.js b/app/assets/javascripts/discourse/controllers/create_account_controller.js index 498b7a4848e..d409757d621 100644 --- a/app/assets/javascripts/discourse/controllers/create_account_controller.js +++ b/app/assets/javascripts/discourse/controllers/create_account_controller.js @@ -295,33 +295,34 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF }); }, - createAccount: function() { - var createAccountController = this; - this.set('formSubmitted', true); - var name = this.get('accountName'); - var email = this.get('accountEmail'); - var password = this.get('accountPassword'); - var username = this.get('accountUsername'); - var passwordConfirm = this.get('accountPasswordConfirm'); - var challenge = this.get('accountChallenge'); - return Discourse.User.createAccount(name, email, password, username, passwordConfirm, challenge).then(function(result) { - if (result.success) { - createAccountController.flash(result.message); - createAccountController.set('complete', true); - } else { - createAccountController.flash(result.message || I18n.t('create_account.failed'), 'error'); - if (result.errors && result.errors.email && result.values) { - createAccountController.get('rejectedEmails').pushObject(result.values.email); + actions: { + createAccount: function() { + var createAccountController = this; + this.set('formSubmitted', true); + var name = this.get('accountName'); + var email = this.get('accountEmail'); + var password = this.get('accountPassword'); + var username = this.get('accountUsername'); + var passwordConfirm = this.get('accountPasswordConfirm'); + var challenge = this.get('accountChallenge'); + return Discourse.User.createAccount(name, email, password, username, passwordConfirm, challenge).then(function(result) { + if (result.success) { + createAccountController.flash(result.message); + createAccountController.set('complete', true); + } else { + createAccountController.flash(result.message || I18n.t('create_account.failed'), 'error'); + if (result.errors && result.errors.email && result.values) { + createAccountController.get('rejectedEmails').pushObject(result.values.email); + } + createAccountController.set('formSubmitted', false); } + if (result.active) { + return window.location.reload(); + } + }, function() { createAccountController.set('formSubmitted', false); - } - if (result.active) { - return window.location.reload(); - } - }, function() { - createAccountController.set('formSubmitted', false); - return createAccountController.flash(I18n.t('create_account.failed'), 'error'); - }); + return createAccountController.flash(I18n.t('create_account.failed'), 'error'); + }); + } } - });