Sha256: 9a3a222415aadfe0bf7729e85e6caf63153c6bacab06c8600e2222ebca0008b5
Contents?: true
Size: 869 Bytes
Versions: 1
Compression:
Stored size: 869 Bytes
Contents
# frozen_string_literal: true module CurrentSession module SessionMethods # # Implementation of session tokens for DB management # module ActiveRecordSession def find session_token_class.find_by(value: session_token).try do |record| update(record) yield record.user end end def create(user) session_token_class.create(user_id: user.id, value: new_session_token) do |record| update(record) yield record.value end end def destroy session_token_class.find_by(value: session_token)&.destroy end private def update(token) token.update( last_request_at: current_time, last_request_ip: request.remote_ip, last_request_user_agent: request.user_agent ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
current_session-0.1.6 | lib/current_session/session_methods/active_record_session.rb |