FIX: not found message when trying to log in with a link, even though the email with the link was successfully sent

This commit is contained in:
Neil Lalonde 2018-03-19 16:08:10 -04:00
parent 4d44024c82
commit a9de712eed
2 changed files with 40 additions and 4 deletions

View File

@ -236,10 +236,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
const loginName = escapeExpression(this.get('loginName'));
const isEmail = loginName.match(/@/);
let key = `email_login.complete_${isEmail ? 'email' : 'username'}`;
if (data.user_found) {
this.flash(I18n.t(`${key}_found`, { email: loginName, username: loginName }));
} else {
if (data.user_found === false) {
this.flash(I18n.t(`${key}_not_found`, { email: loginName, username: loginName }), 'error');
} else {
this.flash(I18n.t(`${key}_found`, { email: loginName, username: loginName }));
}
}).catch(e => {
this.flash(extractError(e), 'error');

View File

@ -17,7 +17,7 @@ acceptance("Login with email", {
};
server.post('/u/email-login', () => { // eslint-disable-line no-undef
return response({ "user_found": userFound });
return response({ "success": "OK", "user_found": userFound });
});
}
});
@ -115,3 +115,39 @@ QUnit.test("logging in via email (button)", assert => {
);
});
});
acceptance("Login with email", {
settings: {
enable_local_logins_via_email: true,
enable_facebook_logins: true,
hide_email_address_taken: true
},
beforeEach() {
const response = object => {
return [
200,
{ "Content-Type": "application/json" },
object
];
};
server.post('/u/email-login', () => { // eslint-disable-line no-undef
return response({ "success": "OK" });
});
}
});
QUnit.test("login via email with hide_email_address_taken enabled", assert => {
visit("/");
click("header .login-button");
fillIn("#login-account-name", 'someuser@example.com');
click('.login-with-email-button');
andThen(() => {
assert.equal(
find(".alert-success").html().trim(),
I18n.t('email_login.complete_email_found', { email: 'someuser@example.com' }),
'it should display the success message for any email address'
);
});
});