Sha256: 718e5ee67559a8940ac819f82444fb2aa3f61278d208c24d23f678c7dd6f57b3

Contents?: true

Size: 850 Bytes

Versions: 12

Compression:

Stored size: 850 Bytes

Contents

require 'md5'

class OrangeMember < Orange::Carton
  id
  front do
    text :first_name
    text :last_name
    text :email
    text :position
    text :company
  end  
  text :hashed_password
  text :salt
  text :reset_token
  property :reset_on, DateTime
  
  def password=(val)
    salt = self.salt
    attribute_set(:hashed_password, Digest::MD5.hexdigest("#{salt}orange-is-awesome#{val}"))
  end
  
  def salt
    my_salt = attribute_get(:salt)
    unless(my_salt)
      my_salt = Digest::MD5.hexdigest(Time.now.iso8601)
      attribute_set(:salt, my_salt)
    end
    my_salt
  end
  
  def reset!
    token = Digest::MD5.hexdigest(Time.now.iso8601)
    # Invalidate password
    attribute_set(:hashed_password, Digest::MD5.hexdigest("#{salt}#{token}"))
    attribute_set(:reset_on, DateTime)
    attribute_set(:reset_token, token)
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
orange-0.3.8 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.7 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.6 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.5 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.4 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.3 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.2 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.1 lib/orange-more/members/cartons/member_carton.rb
orange-0.3.0 lib/orange-more/members/cartons/member_carton.rb
orange-0.2.11 lib/orange-more/members/cartons/member_carton.rb
orange-0.2.9 lib/orange-more/members/cartons/member_carton.rb
orange-0.2.8 lib/orange-more/members/cartons/member_carton.rb