Sha256: b24e3dd115f6a1777b893b5fa8b07821eb42bb439021671c6bffb84ddc1a51f7
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 KB
Contents
class LoginController < ApplicationController def index # Ask user for their #{shop}.myshopify.com address # If the #{shop}.myshopify.com address is already provided in the URL, just skip to #authenticate if params[:shop].present? redirect_to authenticate_path(:shop => params[:shop]) end end def authenticate if params[:shop].present? redirect_to ShopifyAPI::Session.new(params[:shop].to_s.strip).create_permission_url else redirect_to return_address end end # Shopify redirects the logged-in user back to this action along with # the authorization token t. # # This token is later combined with the developer's shared secret to form # the password used to call API methods. def finalize shopify_session = ShopifyAPI::Session.new(params[:shop], params[:t], params) if shopify_session.valid? session[:shopify] = shopify_session flash[:notice] = "Logged in to shopify store." redirect_to return_address session[:return_to] = nil else flash[:error] = "Could not log in to Shopify store." redirect_to :action => 'index' end end def logout session[:shopify] = nil flash[:notice] = "Successfully logged out." redirect_to :action => 'index' end protected def return_address session[:return_to] || root_url end end
Version data entries
4 entries across 4 versions & 1 rubygems