mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
SECURITY: Validate email constraints when trying to redeem an invite
In certain situations, a logged in user can redeem an invite with an email that either doesn't match the invite's email or does not adhere to the email domain restriction of an invite link. The impact of this flaw is aggrevated when the invite has been configured to add the user that accepts the invite into restricted groups.
This commit is contained in:

committed by
David Taylor

parent
03ffb0bf27
commit
115859964d
@ -165,11 +165,8 @@ class Invite < ActiveRecord::Base
|
||||
def redeem(email: nil, username: nil, name: nil, password: nil, user_custom_fields: nil, ip_address: nil, session: nil, email_token: nil)
|
||||
return if !redeemable?
|
||||
|
||||
if is_invite_link? && UserEmail.exists?(email: email)
|
||||
raise UserExists.new I18n.t("invite_link.email_taken")
|
||||
end
|
||||
|
||||
email = self.email if email.blank? && !is_invite_link?
|
||||
|
||||
InviteRedeemer.new(
|
||||
invite: self,
|
||||
email: email,
|
||||
|
Reference in New Issue
Block a user