Sha256: 2ff9e0ab67ba620660057b3ba9ea3795e05714be03428129d8f34aa67b54edcb

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

# :namespace
module Credentials
  
# Associates an e-mail address with the user account.
class Email < ::Credential
  # The e-mail address.
  alias_attribute :email, :name
  validates :name, :format => /^[A-Za-z0-9.+_]+@[^@]*\.(\w+)$/,
       :presence => true, :uniqueness => { :scope => [:type],
       :message => 'This e-mail address is already claimed by an account' }

  # '1' if the user proved ownership of the e-mail address.
  alias_attribute :verified, :key
  validates :verified, :presence => true

  before_validation :set_verified_to_false, :on => :create
  # :nodoc: by default, e-mail addresses are not verified
  def set_verified_to_false
    self.verified ||= '0' if self.key.nil?
  end

  # Forms can only change the e-mail in the credential.
  attr_accessible :email
end  # class Credentials::Email 

end  # namespace Credentials

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authpwn_rails-0.10.3 app/models/credentials/email.rb
authpwn_rails-0.10.2 app/models/credentials/email.rb