Skip to content

Instantly share code, notes, and snippets.

@edavis10
Created May 6, 2016 20:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edavis10/74b2c35f9b998830b4858ef66218cb3e to your computer and use it in GitHub Desktop.
Save edavis10/74b2c35f9b998830b4858ef66218cb3e to your computer and use it in GitHub Desktop.
class SessionsController < ApplicationController
include ShopifyApp::SessionsController
before_filter :check_allowed_shops, only: :new
private
# Checks that the shop attempting to login (starting OAuth flow) is allowed
def check_allowed_shops
if params[:shop].present?
if allowed_shops.include?(params[:shop].gsub(".myshopify.com",""))
return true # Allowed
else
redirect_to login_path
return false
end
end
end
# Domains of shops to allow.
#
# The myshopify.com subdomain without the myshopify.com part
def allowed_shops
["shop1","shop2","shop3"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment