Class: Organizations::Domain
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Organizations::Domain
- Defined in:
- lib/organizations/models/domain.rb
Overview
An email domain owned/claimed by an organization, used for verified joining.
A user who proves control of an inbox under one of the organization's domains (emailed code, or an already-confirmed account email — see Organization#join_with_account_email!) is considered a verified member.
Matching is EXACT and dot-boundary safe: "alumnos.urjc.es" and "urjc.es" are two different domains and must both be enrolled if both should join. This is deliberate — subdomains often carry different member semantics (e.g. students vs employees), and suffix matching would collapse them. It also neutralizes lookalike attacks ("urjc.es.evil.com" never equals "urjc.es").
membership_metadata is copied onto memberships created through this
domain (see JoinRequest#approve!) — hosts use it for cohort tags like
{ "member_kind" => "student" } without the gem interpreting the contents.
Instance Method Summary collapse
-
#matches_email?(email) ⇒ Boolean
Whether an email address belongs to this domain (exact match).
Instance Method Details
#matches_email?(email) ⇒ Boolean
Whether an email address belongs to this domain (exact match).
59 60 61 62 |
# File 'lib/organizations/models/domain.rb', line 59 def matches_email?(email) extracted = EmailNormalizer.domain_of(email) extracted.present? && extracted == domain end |