Skip to content

Commit

Permalink
update redirect policy
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebeel committed Dec 6, 2020
1 parent db3c613 commit 43a6db7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/auth/redirection-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ type RedirectionParams = {
export default function redirectionScript({
origin,
redirectTo,
apiKey
apiKey,
}: RedirectionParams) {
return `
<script src="https://unpkg.com/@shopify/app-bridge@^1"></script> <script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
if (window.top === window.self) {
// If the current window is the 'parent', change the URL by setting location.href
window.location.href = "${redirectTo}";
} else {
// If the current window is the 'child', change the parent's URL with postMessage
// If the current window is the 'child', change the parent's URL with postMessage
var AppBridge = window['app-bridge'];
var createApp = AppBridge.default;
var Redirect = AppBridge.actions.Redirect;
Expand All @@ -26,7 +22,6 @@ export default function redirectionScript({
});
var redirect = Redirect.create(app);
redirect.dispatch(Redirect.Action.REMOTE, "${redirectTo}");
}
});
</script>
`;
Expand Down
2 changes: 2 additions & 0 deletions src/verify-request/verify-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default async function verifyRequest({
};

const shopFromQuery = Array.isArray(query.shop) ? query.shop[0] : query.shop;
console.log("lib", cookies)
console.log("shop", shopFromQuery)
if (shopFromQuery && cookies.shopOrigin) {
if (shopFromQuery !== cookies.shopOrigin) {
// go through login process if different shops
Expand Down

0 comments on commit 43a6db7

Please sign in to comment.