Sha256: fd9f16f697d18d2358df2ace954cb738cf79984259e9e6b4c9692d7bd78daddc
Contents?: true
Size: 1.1 KB
Versions: 7
Compression:
Stored size: 1.1 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 "/auth/shopify?shop=#{params[:shop].to_s.strip}" else redirect_to return_address end end def finalize if response = request.env['omniauth.auth'] sess = ShopifyAPI::Session.new(params['shop'], response['credentials']['token']) session[:shopify] = sess flash[:notice] = "Logged in" 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
7 entries across 7 versions & 1 rubygems