Class: User

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::SecurePassword, Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
Defined in:
lib/generators/iceauth/templates/app/models/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authenticate_with_salt(id, cookie_salt) ⇒ Object



43
44
45
46
# File 'lib/generators/iceauth/templates/app/models/user.rb', line 43

def self.authenticate_with_salt(id, cookie_salt)
  user = User.where(:_id => id).first
  (user && user.salt == cookie_salt) ? user : nil
end

Instance Method Details

#saltObject



39
40
41
# File 'lib/generators/iceauth/templates/app/models/user.rb', line 39

def salt
  BCrypt::Password.new(password_digest).salt unless password_digest.blank?
end

#toggle_admin!Object



48
49
50
51
# File 'lib/generators/iceauth/templates/app/models/user.rb', line 48

def toggle_admin!
  self.admin = !admin
  save :validate => false
end