mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:52:45 +08:00
UX: Improve invite error message when a user uses an email that has already redeemed (#25695)
Improve invite error message when a user uses an email that has already redeemed
This commit is contained in:
parent
fe851a533a
commit
a8a39d86b4
|
@ -192,7 +192,7 @@ class InviteRedeemer
|
|||
redeeming_user ||= User.where(admin: false, staged: false).find_by_email(email)
|
||||
if redeeming_user.present? &&
|
||||
InvitedUser.exists?(user_id: redeeming_user.id, invite_id: invite.id)
|
||||
return false
|
||||
raise Invite::UserExists.new(I18n.t("invite.existing_user_already_redemeed"))
|
||||
end
|
||||
|
||||
true
|
||||
|
|
|
@ -587,13 +587,15 @@ RSpec.describe InviteRedeemer do
|
|||
expect(invite_link.redemption_count).to eq(1)
|
||||
end
|
||||
|
||||
it "should not redeem the invite if InvitedUser record already exists for email" do
|
||||
it "raises an error if email has already been invited" do
|
||||
invite_redeemer.redeem
|
||||
invite_link.reload
|
||||
|
||||
another_invite_redeemer = InviteRedeemer.new(invite: invite_link, email: "foo@example.com")
|
||||
another_user = another_invite_redeemer.redeem
|
||||
expect(another_user).to eq(nil)
|
||||
expect { another_invite_redeemer.redeem }.to raise_error(
|
||||
Invite::UserExists,
|
||||
I18n.t("invite.existing_user_already_redemeed"),
|
||||
)
|
||||
end
|
||||
|
||||
it "should redeem the invite if InvitedUser record does not exists for email" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user