Module: PagesCore::AuthenticableUser
- Extended by:
- ActiveSupport::Concern
- Included in:
- User
- Defined in:
- app/models/concerns/pages_core/authenticable_user.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#can_login? ⇒ Boolean
34 35 36 |
# File 'app/models/concerns/pages_core/authenticable_user.rb', line 34 def can_login? activated? end |
#recovery_codes=(codes) ⇒ Object
38 39 40 41 42 |
# File 'app/models/concerns/pages_core/authenticable_user.rb', line 38 def recovery_codes=(codes) self.hashed_recovery_codes = codes.map do |c| BCrypt::Password.create(c, cost: 8) end end |
#use_recovery_code!(code) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'app/models/concerns/pages_core/authenticable_user.rb', line 44 def use_recovery_code!(code) valid_hashes = hashed_recovery_codes.select do |c| BCrypt::Password.new(c) == code end return false unless valid_hashes.any? update(hashed_recovery_codes: hashed_recovery_codes - valid_hashes) true end |