Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Update jQuery ajax header Authorization setting #790

Merged
merged 5 commits into from Jun 22, 2021

Conversation

thang12l
Copy link
Contributor

Correct Authorization Bearer setting for jQuery ajax header

@squatto
Copy link
Contributor

squatto commented May 19, 2021

@thang12l doesn't doing it the way that you're proposing overwrite any existing custom headers? We changed it to directly set the "Authorization" value in the headers array to avoid that.

Avoid overwrite any existing custom headers
@thang12l
Copy link
Contributor Author

@squatto the proposing way will overwrite custom headers if they exist. Just update it again to avoid it. When no headers exist, use ajaxSetup to add the new setting.

Copy link
Contributor Author

@thang12l thang12l left a comment

Choose a reason for hiding this comment

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

Just updated with the template style

@gnikyt
Copy link
Owner

gnikyt commented Jun 14, 2021

Thanks! I havent used jQuery in a long time, but if window.jQuery.ajaxSettings.headers is undefined, can we just window.jQuery.ajaxSettings.headers = {}; ? Or does that not work, as in, you have to previously have used ajaxSetup?

Use window.jQuery.ajaxSettings.headers = { } instead of ajaxSetup method
@thang12l
Copy link
Contributor Author

@osiset window.jQuery.ajaxSettings.headers = {}; will work like a charm!

@gnikyt
Copy link
Owner

gnikyt commented Jun 21, 2021

@thang12l Nice! Update your PR and ill merge it in.

@thang12l
Copy link
Contributor Author

@osiset , Already done with 7a0aa37. Please merge it in.

@gnikyt gnikyt merged commit d3df995 into gnikyt:feature/cookieless Jun 22, 2021
@thang12l thang12l deleted the feature/cookieless branch June 23, 2021 00:59
gnikyt added a commit that referenced this pull request Jun 25, 2021
* Combined AuthShopify, AuthToken into new VerifyShopify middleware
* SessionToken value object created to verify and validate all aspects of the JWT
* New unauthenticated route and view added
* Removal of ITP, cookie helper, shop session as they're unneeded
* Added Polaris skeleton to token view
* Revised initial package landing page
* Added session ID support
* Moved AuthorizeShop to InstallShop
* Condensed InstallShop and modified to return an array
* Modified InstallShop to track access token update time
* Modified Shop command to track access token update time
* Support for other routes and token usage
* Removed authenticate.oauth route
* Removed oauthfailure method on authenticate controller
* Removed ShopSession class
* Updated shopify-config to reference new authenticate routes (install, token)
* Updated shopify-config to remove old authenticate routes
* Updated ShopModel's getToken to getAccessToken for naming conflict purposes
* Removed old ITP and authenticate routes from built-in route provider
* Updated SHOPIFY_API_REDRIECT to use /install instead of old /authenticate
* Revert authenticate route back to authenticate instead of 'install'
* Updated test class naming for DeleteWebhooks action
* Added TurboLink support
* Change name for test package
* Added getToken helper
* Added missing auth url exception
* Added billing to allowed routes, change token receipt
* Exception added to prevent loop redirects if authorization link is empty
* Added billing payments with tokens
* Removed unused classes
* Added test cases for session token
* Test cases added for session context, verify shop middleware
* Check for "?" in URLs instead of "&" when determining the separator (#777)
* Fix test: use `authenticate.token` instead of `authenticate.oauth` (#776)
* Use `contains()` to support route prefixes (#775)
* Use an env var for the new `turbo_enabled` config setting (#774)
* Updated code to use AuthManager from Laravel instead of auth()
* Updated response codes to use HTTP constants
* Update to BillingController and Billable middleware to remove old ShopSession service
* Remove "token" from the query string of the target URL (#779)
* Feature/cookieless - changes for turbolinks, install app  (#780)
* Redirect if the user clicked on any link before load Turbo
* Find shop domain in request when getting the token (#784)
* Add param to constructor to optionally not verify the token
* Add static method `ShopDomain::getFromRequest()` to find the shop domain
* Remove extraneous `ShopDomain` calls
* Always pass the filtered query params to the token redirect (#785)
* Added TokenRedirect macro for Laravel Redirect
* Added TokenRoute macro for Laravel URL/Route
* Updated ShopDomain::getFromRequest to be ShopDomain::fromRequest for consistency
* Moved HMAC and HMAC generation/comparison to value object (Hmac)
* Move SessionContext to be a composite value object
* Updated to handle Blade session tokens
* Added Blade directive "@sessionToken"
* Added support for jQuery, Turbolinks, and Axios for token bearer
* Added support for ".session-token" to automatically update with the token value
* Update jQuery ajax header Authorization setting (#790)
* Use template style setting for jQuery.ajaxSetup
* Use window.jQuery.ajaxSettings.headers = { } instead of ajaxSetup method
* Clean up on bearer token header settings
* Remove legacy factories package
* Billing flow adjusted to use tokens
* Fix to Kernel testcase referring to old middleware
* Fix to undefined methods for macros
* Remove build and bin folders from repo
* Added test for `tokenRoute`
* Added test for `tokenRedirect`
* Modified `TokenRedirect` and `TokenUrl` macros to use a common base class
* Added test for sessionToken directive
* Fix to SessionContext validity check for domain comparison
* Resolve static method not found for tests on tokenRedirect and tokenRoute

Co-authored-by: Lucas Michot <lucas@semalead.com>
Co-authored-by: Vitaly <32259003+Enmaboya@users.noreply.github.com>
Co-authored-by: Scott Carpenter <scott@payforstay.com>
Co-authored-by: Tyler King <osiset@users.noreply.github.com>
Co-authored-by: Vitaliy Dubov <vdubov@simtechdev.org>
Co-authored-by: Stephen Sweetland <steve.sweetland@gmail.com>
Co-authored-by: Tony Le <55417634+thang12l@users.noreply.github.com>
Co-authored-by: Lucas Michot <lucas@semalead.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants