Sha256: ac696741e4e0d632744e0ec055fd3c5f502d2976934b087ae06de4e266aee299

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 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
end  # class Credentials::Email 

end  # namespace Credentials

# :nodoc: adds e-mail integration to the user model
module Authpwn::UserModel::InstanceMethods
  def email_credential
    credentials.find { |c| c.instance_of?(Credentials::Email) }
  end
end  # module Authpwn::UserModel::InstanceMethods

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authpwn_rails-0.10.0 lib/authpwn_rails/credentials/email.rb