Class: WithAccounts::Account
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- WithAccounts::Account
- Defined in:
- app/models/with_accounts/account.rb
Constant Summary collapse
- LOGIN_INVITATION_TTL =
3.hours
- REFRESH_TOKEN_TTL =
12.hours
- ACCESS_TOKEN_TTL =
1.minute
Instance Method Summary collapse
Instance Method Details
#cipher_decipher(type, timestamp_attr_name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/with_accounts/account.rb', line 24 def cipher_decipher(type, ) = public_send() || created_at cipher = OpenSSL::Cipher.new('aes-256-cbc') case type when :encrypt cipher.encrypt when :decrypt cipher.decrypt else raise StandardError end cipher.tap do _1.key = id.byteslice(0..31) _1.iv = "#{&.strftime('%Y%m%d%H%M%S%6N')}---".byteslice(0..15) end end |