Class | User
In: | app/models/user.rb
Parent: | ActiveRecord::Base

### Methods

after_destroy authenticate password password= validate

### Attributes

password_confirmation | [RW] |

### Public Class methods

authenticate(name, password)

[Source]

        # File app/models/user.rb, line 12
    12:   def self.authenticate(name, password)
    13:     user = self.find_by_name(name)
    14:     if user
    15:       expected_password = encrypted_password(password, user.salt)
    16:       if user.hashed_password != expected_password
    17:         user = nil
    18:       end
    19:     end
    20:     user
    21:   end

### Public Instance methods

after_destroy()

[Source]

        # File app/models/user.rb, line 34
    34:   def after_destroy
    35:     if User.count.zero?
    36:       raise "Nie można usunąć ostatniego użytkownika"
    37:     end
    38:   end

password()

‘password’ jest wirtualnym atrybutem

[Source]

        # File app/models/user.rb, line 24
    24:   def password
    25:     @password
    26:   end

password=(pwd)

[Source]

        # File app/models/user.rb, line 28
    28:   def password=(pwd)
    29:     @password = pwd
    30:     create_new_salt
    31:     self.hashed_password = User.encrypted_password(self.password, self.salt)
    32:   end

validate()

[Source]

        # File app/models/user.rb, line 8
     8:   def validate
     9:     errors.add_to_base("Brak hasła") if hashed_password.blank?
    10:   end

[Validate]