Sha256: b8c9e59ea53ffb5779366567efa4521e0ddcaae5bc1e0406424c3fbbb7a431c5
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module CurrentSession # # Interface for manipulating http request objects # module Interface extend ActiveSupport::Concern class_methods do def call(request) update(request).current_user.present? end def update(request) session_repository(request).try do |repository| repository.find { |user| self.current_user = user } end self end def create(request) auth = @auth_class.new(request) auth.find_or_create_by_auth.try do |user| auth.update(user) session_repository(request).update_session_token(user) end end def destroy(request) self.current_user = nil session_repository(request).try do |repository| repository.destroy repository.delete_session_token end end private def session_repository(request) @session_repository_class.new( request: request, user_class: user_class, session_token_class: session_token_class, current_time: current_time(request) ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
current_session-0.1.4 | lib/current_session/interface.rb |