A platform for community discussion. Free, open, simple.
FIX: not found message when trying to log in with a link, even though the email with the link was successfully sent
Neil Lalondea9de712eeddb
diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6index e051bd190aa..f5cc976902f 100644--- a/app/assets/javascripts/discourse/controllers/login.js.es6+++ b/app/assets/javascripts/discourse/controllers/login.js.es6@@ -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');diff --git a/test/javascripts/acceptance/login-with-email-test.js.es6 b/test/javascripts/acceptance/login-with-email-test.js.es6index beaa78dd0bc..ecd8f161d72 100644--- a/test/javascripts/acceptance/login-with-email-test.js.es6+++ b/test/javascripts/acceptance/login-with-email-test.js.es6@@ -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", '[email protected]');+ click('.login-with-email-button');++ andThen(() => {+ assert.equal(+ find(".alert-success").html().trim(),+ I18n.t('email_login.complete_email_found', { email: '[email protected]' }),+ 'it should display the success message for any email address'+ );+ });+});