Sha256: e359a6a7403da480cc87c22a2b2bd6e7e9638d2b6b2843b8df9770e658578bad
Contents?: true
Size: 831 Bytes
Versions: 4
Compression:
Stored size: 831 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) end.value end def update(token) token.update( last_request_at: current_time, last_request_ip: request.remote_ip, last_request_user_agent: request.user_agent ) end def destroy session_token_class.find_by(value: session_token)&.destroy end end end end
Version data entries
4 entries across 4 versions & 1 rubygems