Skip to content
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

Add redirect to ThemeKit Access when password prefix matches pattern #933

Merged
merged 2 commits into from
May 5, 2021

Conversation

d-koval
Copy link
Contributor

@d-koval d-koval commented May 4, 2021

Description
Themekit needs to make requests either to ThemeKit Access or to Shopify depending on the type of password token that user has. This should have no effect for existing Themekit users.

The solution checks whether user token starts with an identifiable prefix shptka_ and redirect all requests to the Theme Kit Access server.

Additional context
The issue is related to the new public ThemeKit Access app development.

Warn Checklist

  • This changes the interface and requires a Major/Minor version change.
  • I have 🎩'd these changes by using the commands I changed by hand.
  • I have added a dependancy to the project.
  • I have considered any potential impact on node-themekit

@d-koval d-koval requested a review from tanema May 4, 2021 20:31
Copy link
Contributor

@tanema tanema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple style changes but otherwise it looks good

@@ -103,7 +106,16 @@ func (client *HTTPClient) Delete(path string, headers map[string]string) (*http.

// do will issue an authenticated json request to shopify.
func (client *HTTPClient) do(method, path string, body interface{}, headers map[string]string) (*http.Response, error) {
req, err := http.NewRequest(method, client.baseURL.String()+path, nil)
appBaseURL := client.baseURL.String()
themeKitPasswordPrefix := "shptka_"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a constant at the top of the file.

@@ -27,6 +27,7 @@ var (
httpClient = &http.Client{
Timeout: 30 * time.Second,
}
themeKitAccessURL = "https://theme-kit-access.shopifyapps.com/cli"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either make this a constant variable and use it in the Client struct changing the struct in your tests, OR make this a var and reference it in the do method, and alter the var in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the second approach, in that way we avoid modifying HTTPClient struct altogether

@d-koval d-koval merged commit a4ad895 into master May 5, 2021
@d-koval d-koval deleted the theme-kit-access branch May 5, 2021 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants