Sha256: 69b5f73a5b3ffd4834fae5bc068a2f302b16fdf2a7aeed4d64e46535cea943f4
Contents?: true
Size: 918 Bytes
Versions: 5
Compression:
Stored size: 918 Bytes
Contents
module ShopifyApp::LoginProtection extend ActiveSupport::Concern included do rescue_from ActiveResource::UnauthorizedAccess, :with => :close_session end def shopify_session if session[:shopify] begin # session[:shopify] set in LoginController#show ShopifyAPI::Base.activate_session(session[:shopify]) yield ensure ShopifyAPI::Base.clear_session end else session[:return_to] = request.fullpath if request.get? redirect_to login_path(shop: params[:shop]) end end def shop_session session[:shopify] end def login_again_if_different_shop if shop_session && params[:shop] && params[:shop].is_a?(String) && shop_session.url != params[:shop] redirect_to login_path(shop: params[:shop]) end end protected def close_session session[:shopify] = nil redirect_to login_path end end
Version data entries
5 entries across 5 versions & 1 rubygems