Sha256: 9ebfdf3e082ccbd5ccecb27837597c6a334c384910600c2c928cdd12cc6137f9
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 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'] sess = ShopifyAPI::Session.new(params[:shop], response['credentials']['token']) session[:shopify] = ShopifyApp::SessionRepository.store(sess) 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 flash[:notice] = "Successfully logged out." redirect_to action: 'new' end protected def authenticate if shop_name = sanitize_shop_param(params) fullpage_redirect_to "/auth/shopify?shop=#{shop_name}" else redirect_to return_address end end def return_address session[: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.1.1 | lib/shopify_app/sessions_controller.rb |
shopify_app-6.1.0 | lib/shopify_app/sessions_controller.rb |