-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1581 from Shopify/klenotiw/renaming-concerns
Adding Deprecation Logs
- Loading branch information
Showing
30 changed files
with
422 additions
and
153 deletions.
There are no files selected for viewing
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
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
19 changes: 19 additions & 0 deletions
19
app/controllers/concerns/shopify_app/ensure_has_session.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module ShopifyApp | ||
module EnsureHasSession | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include ShopifyApp::Localization | ||
include ShopifyApp::LoginProtection | ||
include ShopifyApp::CsrfProtection | ||
include ShopifyApp::EmbeddedApp | ||
include ShopifyApp::EnsureBilling | ||
|
||
before_action :login_again_if_different_user_or_shop | ||
around_action :activate_shopify_session | ||
after_action :add_top_level_redirection_headers | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# frozen_string_literal: true | ||
|
||
module ShopifyApp | ||
module EnsureInstalled | ||
extend ActiveSupport::Concern | ||
include ShopifyApp::RedirectForEmbedded | ||
|
||
included do | ||
if ancestors.include?(ShopifyApp::LoginProtection) | ||
message = <<~EOS | ||
We detected the use of incompatible concerns (EnsureInstalled and LoginProtection) in #{name}, | ||
which may lead to unpredictable behavior. In a future release of this library this will raise an error. | ||
EOS | ||
|
||
ShopifyApp::Logger.deprecated(message, "22.0.0") | ||
end | ||
|
||
before_action :check_shop_domain | ||
before_action :check_shop_known | ||
end | ||
|
||
def current_shopify_domain | ||
if params[:shop].blank? | ||
ShopifyApp::Logger.info("Could not identify installed store from current_shopify_domain") | ||
return | ||
end | ||
|
||
@shopify_domain ||= ShopifyApp::Utils.sanitize_shop_domain(params[:shop]) | ||
ShopifyApp::Logger.info("Installed store: #{@shopify_domain} - deduced from Shopify Admin params") | ||
@shopify_domain | ||
end | ||
|
||
private | ||
|
||
def check_shop_domain | ||
redirect_to(ShopifyApp.configuration.login_url) unless current_shopify_domain | ||
end | ||
|
||
def check_shop_known | ||
@shop = SessionRepository.retrieve_shop_session_by_shopify_domain(current_shopify_domain) | ||
unless @shop | ||
if embedded_param? | ||
redirect_for_embedded | ||
else | ||
redirect_to(shop_login) | ||
end | ||
end | ||
end | ||
|
||
def shop_login | ||
url = URI(ShopifyApp.configuration.login_url) | ||
|
||
url.query = URI.encode_www_form( | ||
shop: params[:shop], | ||
host: params[:host], | ||
return_to: request.fullpath, | ||
) | ||
|
||
url.to_s | ||
end | ||
end | ||
end |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
lib/generators/shopify_app/authenticated_controller/templates/authenticated_controller.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class AuthenticatedController < ApplicationController | ||
include ShopifyApp::Authenticated | ||
include ShopifyApp::EnsureHasSession | ||
end |
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
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
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
Oops, something went wrong.