Invitations

Invitations can be used for applications that do not require registration but allow users to invite others to the platform.
Through an invitation, it is possible to:

  • Send an invitation email to the user to set up their credentials
  • Track completed registrations
Accepted at
Lato user
Actions
0 total results

Here are some examples of the operations you can perform with invitations:

# creating an invitation (and automatically sending the invite email)
@invitation = Lato::Invitation.create(params.require(:invitation).permit(:email).merge(inviter_lato_user_id: @session.user_id))

# re-sending the invitation email (max 1 every 2 minutes)
@invitation.send_invite

# deleting the invitation
@invitation.destroy

Notes

Auto-email on creation: When an invitation is created, the invite email is automatically sent via an after_create hook. You do not need to call send_invite manually on creation.

Rate limiting: The send_invite method enforces a 2-minute cooldown between emails. If called again before the cooldown expires, it will raise an error.

Destruction guard: Accepted invitations cannot be destroyed. A before_destroy hook prevents deletion if the invitation has already been accepted.

Email uniqueness: The invitation email is validated for uniqueness across all invitations. Additionally, a check ensures no Lato::User already exists with that email address.

Checking Invitation Status

The Lato::Invitation model provides methods to check invitation status:

@invitation = Lato::Invitation.find(id)

# Check if the invitation has been accepted
@invitation.accepted? # returns true/false

# Access the inviter user
@invitation.inviter_lato_user # returns the Lato::User who sent the invitation

# Access the user who accepted (if accepted)
@invitation.lato_user # returns the Lato::User who registered via this invitation
You are offline You are online