Sha256: 3150f107a1cb409d32280f5f5becd0ac1d7ff8516d893a2e5d86779bc73721ee
Contents?: true
Size: 947 Bytes
Versions: 1
Compression:
Stored size: 947 Bytes
Contents
module Kiqr module Controllers module SetCurrentRequestDetails extend ActiveSupport::Concern included do before_action :set_user_and_account_atributes end protected # Set the current user and account based on the request. # This method is called before every action in the controller # and sets the current user and account based on the request. def set_user_and_account_atributes return unless user_signed_in? Kiqr::CurrentAttributes.user = current_user Kiqr::CurrentAttributes.account ||= fetch_account_from_params || current_user&.personal_account end # Fetch the account from the request params def fetch_account_from_params return nil unless params[:account_id].present? current_user.accounts.find_puid!(params[:account_id]) rescue PublicUid::RecordNotFound head :forbidden end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kiqr-0.1.0.alpha1 | lib/kiqr/controllers/set_current_request_details.rb |