diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 8e6c722c6ab..9b94de7b6ab 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -2,7 +2,7 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; import DiscourseController from 'discourse/controllers/controller'; export default DiscourseController.extend(ModalFunctionality, { - needs: ['modal', 'createAccount', 'application'], + needs: ['modal', 'createAccount', 'forgotPassword', 'application'], authenticate: null, loggingIn: false, loggedIn: false, @@ -122,8 +122,22 @@ export default DiscourseController.extend(ModalFunctionality, { createAccount: function() { var createAccountController = this.get('controllers.createAccount'); - createAccountController.resetForm(); + if (createAccountController) { + createAccountController.resetForm(); + var loginName = this.get('loginName'); + if (loginName && loginName.indexOf('@') > 0) { + createAccountController.set("accountEmail", loginName); + } else { + createAccountController.set("accountUsername", loginName); + } + } this.send('showCreateAccount'); + }, + + forgotPassword: function() { + var forgotPasswordController = this.get('controllers.forgotPassword'); + if (forgotPasswordController) { forgotPasswordController.set("accountEmailOrUsername", this.get("loginName")); } + this.send("showForgotPassword"); } }, diff --git a/app/assets/javascripts/discourse/templates/modal/login.hbs b/app/assets/javascripts/discourse/templates/modal/login.hbs index 41568d1c8ee..3034d390d9b 100644 --- a/app/assets/javascripts/discourse/templates/modal/login.hbs +++ b/app/assets/javascripts/discourse/templates/modal/login.hbs @@ -21,7 +21,7 @@ {{password-field value=loginPassword type="password" id="login-account-password" maxlength="200" capsLockOn=capsLockOn}}