FEATURE: carry username or email from login form to the forgot password and signup forms

This commit is contained in:
Neil Lalonde 2015-02-18 15:01:05 -05:00
parent 7209f67898
commit def034cd08
2 changed files with 17 additions and 3 deletions

View file

@ -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');
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");
}
},

View file

@ -21,7 +21,7 @@
{{password-field value=loginPassword type="password" id="login-account-password" maxlength="200" capsLockOn=capsLockOn}}  
</td>
<td>
<a id="forgot-password-link" {{action "showForgotPassword"}}>{{i18n 'forgot_password.action'}}</a>
<a id="forgot-password-link" {{action "forgotPassword"}}>{{i18n 'forgot_password.action'}}</a>
</td>
</tr>
<tr>