Skip to content

Commit

Permalink
Merge pull request #35 from Shopify/kos/add_exitiframe_route
Browse files Browse the repository at this point in the history
Add processing for OAuth flicker reduction
  • Loading branch information
mkevinosullivan authored Aug 22, 2022
2 parents 279ef26 + 3f7545e commit 8fbce7d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ group :test do
gem "webdrivers"
end

gem "shopify_app", "~> 19.0"
gem "shopify_app", "~> 20.1"
8 changes: 6 additions & 2 deletions web/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ class HomeController < ApplicationController
PROD_INDEX_PATH = Rails.public_path.join("dist")

def index
contents = File.read(File.join(Rails.env.production? ? PROD_INDEX_PATH : DEV_INDEX_PATH, "index.html"))
if ShopifyAPI::Context.embedded? && !params[:embedded].present? || params[:embedded] != "1"
redirect_to(ShopifyAPI::Auth.embedded_app_url(params[:host]), allow_other_host: true)
else
contents = File.read(File.join(Rails.env.production? ? PROD_INDEX_PATH : DEV_INDEX_PATH, "index.html"))

render(plain: contents, content_type: "text/html", layout: false)
render(plain: contents, content_type: "text/html", layout: false)
end
end
end
6 changes: 4 additions & 2 deletions web/app/services/application_service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class ApplicationService
def self.call(*args, **kwargs, &block)
new(*args, **kwargs, &block).call
class << self
def call(*args, **kwargs, &block)
new(*args, **kwargs, &block).call
end
end
end
1 change: 1 addition & 0 deletions web/config/initializers/shopify_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
config.root_url = "/api"
config.login_url = "/api/auth"
config.login_callback_url = "/api/auth/callback"
config.embedded_redirect_url = "/ExitIframe"

# You may want to charge merchants for using your app. Setting the billing configuration will cause the Authenticated
# controller concern to check that the session is for a merchant that has an active one-time payment or subscription.
Expand Down
2 changes: 1 addition & 1 deletion web/frontend
Submodule frontend updated 2 files
+4 −0 index.html
+27 −0 pages/ExitIframe.jsx

0 comments on commit 8fbce7d

Please sign in to comment.