diff --git a/app/models/invite_redeemer.rb b/app/models/invite_redeemer.rb index 157e28b5ad1..5bb6d0f1efe 100644 --- a/app/models/invite_redeemer.rb +++ b/app/models/invite_redeemer.rb @@ -11,7 +11,7 @@ InviteRedeemer = Struct.new(:invite, :username, :name, :password, :user_custom_f # If `invite_passthrough_hours` is defined, allow them to re-use the invite link # to login again. if invite.redeemed_at && invite.redeemed_at >= SiteSetting.invite_passthrough_hours.hours.ago - return invited_user + return get_existing_user end nil diff --git a/spec/models/invite_redeemer_spec.rb b/spec/models/invite_redeemer_spec.rb index f71f9de29b7..dea7ea2945d 100644 --- a/spec/models/invite_redeemer_spec.rb +++ b/spec/models/invite_redeemer_spec.rb @@ -128,5 +128,18 @@ describe InviteRedeemer do expect(user.group_users.count).to eq(4) expect(user.trust_level).to eq(2) end + + it "only allows one user to be created per invite" do + SiteSetting.invite_passthrough_hours = 4800 + user = invite_redeemer.redeem + invite.reload + + user.email = "john@example.com" + user.save! + + another_invite_redeemer = InviteRedeemer.new(invite, username, name) + another_user = another_invite_redeemer.redeem + expect(another_user).to eq(nil) + end end end