Sha256: afd94b822b4681f8995b811532bdbe2da62c60dc2a6e981f1cc1cd31f172bee4
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
module ShopifyApp module SessionsController extend ActiveSupport::Concern def new authenticate if params[:shop].present? end def create authenticate end def callback if response = request.env['omniauth.auth'] shop_name = response.uid sess = ShopifyAPI::Session.new(shop_name, response['credentials']['token']) session[:shopify] = ShopifyApp::SessionRepository.store(sess) session[:shopify_domain] = shop_name flash[:notice] = "Logged in" redirect_to return_address else flash[:error] = "Could not log in to Shopify store." redirect_to action: 'new' end end def destroy session[:shopify] = nil session[:shopify_domain] = nil flash[:notice] = "Successfully logged out." redirect_to action: 'new' end protected def authenticate if shop_name = sanitize_shop_param(params) fullpage_redirect_to "#{main_app.root_path}auth/shopify?shop=#{shop_name}" else redirect_to return_address end end def return_address session.delete(:return_to) || main_app.root_url end def sanitized_shop_name @sanitized_shop_name ||= sanitize_shop_param(params) end def sanitize_shop_param(params) return unless params[:shop].present? ShopifyApp::Utils.sanitize_shop_domain(params[:shop]) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shopify_app-6.2.1 | lib/shopify_app/sessions_controller.rb |
shopify_app-6.2.0 | lib/shopify_app/sessions_controller.rb |