Sha256: 3fd7fccc637492ee5e2340c641ec4aacc2ca546999769da9ee525ecccff57d96
Contents?: true
Size: 1.51 KB
Versions: 70
Compression:
Stored size: 1.51 KB
Contents
module Authentication mattr_accessor :login_regex, :bad_login_message, :name_regex, :bad_name_message, :email_name_regex, :domain_head_regex, :domain_tld_regex, :email_regex, :bad_email_message self.login_regex = /\A\w[\w\.\-_@]+\z/ # ASCII, strict # self.login_regex = /\A[[:alnum:]][[:alnum:]\.\-_@]+\z/ # Unicode, strict # self.login_regex = /\A[^[:cntrl:]\\<>\/&]*\z/ # Unicode, permissive self.bad_login_message = "use only letters, numbers, and .-_@ please.".freeze self.name_regex = /\A[^[:cntrl:]\\<>\/&]*\z/ # Unicode, permissive self.bad_name_message = "avoid non-printing characters and \\><&/ please.".freeze self.email_name_regex = '[\w\.%\+\-]+'.freeze self.domain_head_regex = '(?:[A-Z0-9\-]+\.)+'.freeze self.domain_tld_regex = '(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum)'.freeze self.email_regex = /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i self.bad_email_message = "should look like an email address.".freeze def self.included(recipient) recipient.extend(ModelClassMethods) recipient.class_eval do include ModelInstanceMethods end end module ModelClassMethods def secure_digest(*args) Digest::SHA1.hexdigest(args.flatten.join('--')) end def make_token secure_digest(Time.now, (1..10).map{ rand.to_s }) end end # class methods module ModelInstanceMethods end # instance methods end
Version data entries
70 entries across 70 versions & 13 rubygems