Sha256: 973c2885c55761a5c830742eeea64f9c7c854ceb8b7e6b9e2e4c8acb7188decc
Contents?: true
Size: 929 Bytes
Versions: 4
Compression:
Stored size: 929 Bytes
Contents
# frozen_string_literal: true module CurrentSession # # Base class for processing to get session_token from request.session # class Repository def initialize(current_time:, request:, user_class:, session_token_class:) @current_time = current_time @request = request @user_class = user_class @session_token_class = session_token_class end attr_reader :current_time, :request, :user_class, :session_token_class def key @key ||= CurrentSession.key(user_class) end def session_token @session_token ||= request.session[key] end def new_session_token SecureRandom.urlsafe_base64(64) end def delete_session_token request.session.delete(key) end def update_session_token(user) request.session[key] = create(user) end def try session_token.presence.try do |_| yield self end end end end
Version data entries
4 entries across 4 versions & 1 rubygems