Sha256: 4e73c9a6d389e38ad507be228c92e16e7a2e2726ed35ebf9921ba02a30bf1163

Contents?: true

Size: 883 Bytes

Versions: 2

Compression:

Stored size: 883 Bytes

Contents


class Logman
  class User
    include Mongoid::Document
    include ActiveModel::SecurePassword
    
    store_in collection: 'logman_users'
    
    attr_accessible :email, :password, :name, :admin
    
    validates_presence_of :email, :name
    validates_presence_of :password, :on=> :create
    validates_uniqueness_of :email
    validates_format_of :email, with: /.+\@.+\..+/
    
    field :email, type: String
    field :password_digest, type: String
    field :name, type: String 
    field :admin, type: Boolean
    
    has_secure_password
    
    # buckets that user have access     
    def buckets
      return Bucket.all if self.admin
      
      Bucket.where(:user_ids=> self.id)
    end
    
    
    def serializable_hash(options={})
      options[:methods] ||= [:id]
      options[:except] ||= [:password_digest]
      super(options)
    end
    
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logman-0.1.0 lib/models/user.rb
logman-0.1.0.alpha lib/models/user.rb