Class: Invite

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/invite.rb

Overview

An invitation, tracks the sender and recipient, and what the recipient is invited to. Generates a unique token for each invitation. The token is used in the invite url to (more) securely identify the invite when a new user clicks to register.

Instance Method Summary collapse

Instance Method Details

#check_recipient_existenceObject



26
27
28
29
# File 'app/models/invite.rb', line 26

def check_recipient_existence
  recipient = Invitation.configuration.user_model.find_by_email(email)
  self.recipient_id = recipient.id if recipient
end

#existing_user?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/invite.rb', line 18

def existing_user?
  recipient != nil
end

#generate_tokenObject



22
23
24
# File 'app/models/invite.rb', line 22

def generate_token
  self.token = SecureRandom.hex(20).encode('UTF-8')
end