Merge pull request #2542 from techAPJ/patch-1

FEATURE: topic support in disposable invites
This commit is contained in:
Robin Ward
2014-07-15 15:15:19 -04:00
3 changed files with 54 additions and 3 deletions

View File

@ -168,10 +168,11 @@ class Invite < ActiveRecord::Base
invite
end
def self.redeem_from_token(token, email, username=nil, name=nil)
def self.redeem_from_token(token, email, username=nil, name=nil, topic_id=nil)
invite = Invite.find_by(invite_key: token)
if invite
invite.update_column(:email, email)
invite.topic_invites.create!(invite_id: invite.id, topic_id: topic_id) if topic_id && Topic.find_by_id(topic_id)
user = InviteRedeemer.new(invite, username, name).redeem
end
user