Sha256: cd79e088d51abf5ebfa32d1921e10806259cf0dabd0531e23bfb00af73b69920
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# -*- encoding : utf-8 -*- include_set Abstract::AccountField assign_type :phrase event :validate_email, :validate, on: :save do return unless content? self.content = content.strip return if content.match?(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i) errors.add :content, t(:account_error_invalid_address) end event :validate_unique_email, after: :validate_email, on: :save do if content.present? Auth.as_bot do cql = { right_id: EmailID, eq: content, return: :id } cql[:not] = { id: id } if id cql_comment = t(:account_search_email_duplicate, content: content) if Card.search(cql, cql_comment).first errors.add :content, t(:account_error_not_unique) end end end end event :downcase_email, :prepare_to_validate, on: :save do return if !content || content == content.downcase self.content = content.downcase end def email_required? !left&.left&.codename == :wagn_bot end def ok_to_read? if own_email? || Auth.always_ok? true else deny_because t(:account_deny_email_restricted) end end def own_email? name.part_names[0].key == Auth.as_card.key end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
card-mod-account-0.18.1 | set/right/email.rb |
card-mod-account-0.18.0 | set/right/email.rb |
card-mod-account-0.17.0 | set/right/email.rb |