Module: Breath::Model

Extended by:
ActiveSupport::Concern
Defined in:
lib/breath/model/breath_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#remember_tokenObject

Returns the value of attribute remember_token.



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

def remember_token
  @remember_token
end

Instance Method Details

#forgetObject



45
46
47
# File 'lib/breath/model/breath_model.rb', line 45

def forget
  update_attribute(:remember_digest, nil)
end

#rememberObject

永続的セッションで使用するユーザーをデータベースに記憶する



35
36
37
38
# File 'lib/breath/model/breath_model.rb', line 35

def remember
  self.remember_token = self.class.new_token
  update_attribute(:remember_digest, self.class.digest(remember_token))
end

#remember?(remember_token) ⇒ Boolean

渡されたトークンがダイジェストと一致したらtrueを返す

Returns:

  • (Boolean)


41
42
43
# File 'lib/breath/model/breath_model.rb', line 41

def remember?(remember_token)
  BCrypt::Password.new(remember_digest).is_password?(remember_token)
end