Class: Clerk::SessionToken
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Clerk::SessionToken
- Defined in:
- app/models/clerk/session_token.rb
Class Method Summary collapse
Methods inherited from ApplicationRecord
clerk_table_name, clerk_table_name_nc, transaction
Class Method Details
.find_account(cookie:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/clerk/session_token.rb', line 8 def self.find_account(cookie:) require "bcrypt" begin id, token, token_hash = Clerk.decrypt().split("--") if BCrypt::Password.new(token_hash) == token Account.joins(:session_token).where(token_hash: token_hash, ) SessionToken.eager_load(:account).find_by!(id: id, token_hash: token_hash)&.account else nil end rescue => e puts "Error finding acount #{e}" puts "Cookie #{}" nil end end |