Sha256: e72a4055465e439aa2e88937d2ea7279678c90989ad87c800687072ddb7b4348
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
# -*- encoding : utf-8 -*- class Card; module Set; class Right # Set: All "+Email" cards # # -*- encoding : utf-8 -*- module Email; extend Card::Set def self.source_location; "/Users/ezl5238/dev/decko/gem/mod/account/set/right/email.rb"; end include_set Abstract::AccountField 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.system? 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 end;end;end;end; # ~~ generated from /Users/ezl5238/dev/decko/gem/mod/account/set/right/email.rb ~~
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
card-1.102.0 | tmpsets/set/mod010-account/right/email.rb |