-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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