-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace isStorefrontPasswordProtected with API call #5166
base: main
Are you sure you want to change the base?
Conversation
We were previously determining whether or not a storefront was password protected by making a HTTP request to the storefront and checking the response status. This worked for us in the past but is a known fragile piece. We've now shipped the ability to query whether the storefront is password protected directly in the Admin API so we no longer need to guess. This replaces all instances of `isStorefrontPasswordProtected` with the updated API call.
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationspackages/cli-kit/dist/cli/api/graphql/admin/generated/online_store_password_protection.d.tsimport * as Types from './types.js';
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type OnlineStorePasswordProtectionQueryVariables = Types.Exact<{
[key: string]: never;
}>;
export type OnlineStorePasswordProtectionQuery = {
onlineStore: {
passwordProtection: {
enabled: boolean;
};
};
};
export declare const OnlineStorePasswordProtection: DocumentNode<OnlineStorePasswordProtectionQuery, Types.Exact<{
[key: string]: never;
}>>;
Existing type declarationspackages/cli-kit/dist/public/node/themes/api.d.ts@@ -22,4 +22,5 @@ export declare function metafieldDefinitionsByOwnerType(type: MetafieldOwnerType
name: string;
category: string;
};
-}[]>;
\ No newline at end of file
+}[]>;
+export declare function passwordProtected(session: AdminSession): Promise<boolean>;
\ No newline at end of file
|
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success1996 tests passing in 903 suites. Report generated by 🧪jest coverage report action from 222bc76 |
|
||
const redirectLocation = new URL(response.url) | ||
return redirectLocation.pathname.endsWith('/password') | ||
export async function isPasswordProtected(session: AdminSession): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we had a better distinction internally between the theme-access password and the storefront password.
I've gotten confused by this before, which is why I chose the extremely verbose name. I'm ok with this name.
I'll leave this comment for future devs for the case that someone else is reading this in the future due to naming confusion,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using "Password Protected" makes it clear to me but I see what you mean. Ideally anytime we're referring to the --password
flag we're calling it more like a "token".
WHY are these changes introduced?
We were previously determining whether or not a storefront was password protected by making a HTTP request to the storefront and checking the response status. This worked for us in the past but is a known fragile piece.
We've now shipped the ability to query whether the storefront is password protected directly in the Admin API so we no longer need to guess. This replaces all instances of
isStorefrontPasswordProtected
with the updated API call.WHAT is this pull request doing?
Replaces a fragile process of guessing the meaning of an HTTP status code with making an explicit call to the Admin API to determine whether or not a storefront is password protected.
How to test your changes?
gg-query-password-setting
and runpnpm install && pnpm run build
shopify theme dev --path <local theme path>
shopify theme dev --path <local theme path>
Checklist