Class: Kryptonite::User

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/kryptonite/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#notify_of_new_passwordObject

Returns the value of attribute notify_of_new_password.



16
17
18
# File 'app/models/kryptonite/user.rb', line 16

def notify_of_new_password
  @notify_of_new_password
end

Class Method Details

.has_more_than_one_adminObject



29
30
31
# File 'app/models/kryptonite/user.rb', line 29

def self.has_more_than_one_admin
  Kryptonite::User.where(:access_level => $KRYPTONITE_USER_ACCESS_LEVEL_ADMIN).count > 1
end

.table_nameObject



10
11
12
# File 'app/models/kryptonite/user.rb', line 10

def self.table_name
  self.to_s.gsub("::", "_").tableize
end

Instance Method Details

#check_time_zoneObject



49
50
51
# File 'app/models/kryptonite/user.rb', line 49

def check_time_zone
  self.time_zone = Rails.configuration.time_zone unless self.time_zone
end

#is_admin?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/kryptonite/user.rb', line 53

def is_admin?
  access_level == $KRYPTONITE_USER_ACCESS_LEVEL_ADMIN
end

#is_user?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/models/kryptonite/user.rb', line 57

def is_user?
  access_level == $KRYPTONITE_USER_ACCESS_LEVEL_USER
end

#send_create_notificationObject



33
34
35
# File 'app/models/kryptonite/user.rb', line 33

def send_create_notification
  Kryptonite::KryptoniteNotification.new_user_information(kryptonite_config_email_from_address, self, kryptonite_config_hostname, @password).deliver
end

#send_password_reset_instructionsObject



44
45
46
47
# File 'app/models/kryptonite/user.rb', line 44

def send_password_reset_instructions
  reset_perishable_token!
  Kryptonite::KryptoniteNotification.password_reset_instructions(kryptonite_config_email_from_address, self, kryptonite_config_hostname).deliver
end

#send_update_notificationObject



37
38
39
40
41
42
# File 'app/models/kryptonite/user.rb', line 37

def send_update_notification
  if notify_of_new_password
    notify_of_new_password = false
    Kryptonite::KryptoniteNotification.generate_new_password(kryptonite_config_email_from_address, self, kryptonite_config_hostname, @password).deliver
  end
end