mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:33:24 +08:00
FIX: Incorrect message when logging in via email
If `hide email address taken` was true, it would always display a success message, rather than the non-comittal "maybe we emailed that user" response.
This commit is contained in:
parent
3ad5cb0cbc
commit
ec21a15fa7
|
@ -296,8 +296,12 @@ export default Controller.extend(ModalFunctionality, {
|
|||
"error"
|
||||
);
|
||||
} else {
|
||||
let postfix = data.hide_taken ? "" : "_found";
|
||||
this.flash(
|
||||
I18n.t(`${key}_found`, { email: loginName, username: loginName })
|
||||
I18n.t(`${key}${postfix}`, {
|
||||
email: loginName,
|
||||
username: loginName
|
||||
})
|
||||
);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -748,6 +748,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
json = success_json
|
||||
json[:hide_taken] = SiteSetting.hide_email_address_taken
|
||||
json[:user_found] = user_presence unless SiteSetting.hide_email_address_taken
|
||||
render json: json
|
||||
rescue RateLimiter::LimitExceeded
|
||||
|
|
|
@ -3455,7 +3455,6 @@ describe UsersController do
|
|||
|
||||
it 'should return the right response' do
|
||||
post "/u/email-login.json", params: { login: user.email }
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
|
@ -3465,7 +3464,9 @@ describe UsersController do
|
|||
post "/u/email-login.json", params: { login: '@random' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['user_found']).to eq(false)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['user_found']).to eq(false)
|
||||
expect(json['hide_taken']).to eq(false)
|
||||
expect(Jobs::CriticalUserEmail.jobs).to eq([])
|
||||
end
|
||||
end
|
||||
|
@ -3476,7 +3477,9 @@ describe UsersController do
|
|||
post "/u/email-login.json", params: { login: user.email }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body).has_key?('user_found')).to eq(false)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json.has_key?('user_found')).to eq(false)
|
||||
expect(json['hide_taken']).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user