Module: Entrance::Model

Defined in:
lib/entrance/model.rb

Defined Under Namespace

Modules: ClassMethods, RememberMethods, RemoteAuthMethods, ResetMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/entrance/model.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#authenticated?(string) ⇒ Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/entrance/model.rb', line 133

def authenticated?(string)
  Entrance.config.cipher.match?(read_password, string, get_salt)
end

#passwordObject



137
138
139
# File 'lib/entrance/model.rb', line 137

def password
  @password || read_password
end

#password=(new_password) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/entrance/model.rb', line 141

def password=(new_password)
  return if new_password.nil?

  @password = new_password # for validation
  @password_changed = true

  # if we're using salt and it is empty, generate one
  if Entrance.fields.salt \
    and send(Entrance.fields.salt).nil?
      self.send(Entrance.fields.salt + '=', Entrance.generate_token)
  end

  self.send(Entrance.fields.password + '=', encrypt_password(new_password))
end