Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shopifypartners/d39a2971da88000a44baca2459e7de0c to your computer and use it in GitHub Desktop.
Save shopifypartners/d39a2971da88000a44baca2459e7de0c to your computer and use it in GitHub Desktop.
Session controller for building a Shopify app in one week - https://www.shopify.com/partners/blog/building-a-shopify-app-in-one-week
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