fix: storefront login 403, cookie path, double-storefront URLs, and auth redirects
- Extract store/platform context from Referer header for storefront API requests
(StoreContextMiddleware and PlatformContextMiddleware) so login POST works in
dev mode where API paths lack /platforms/{code}/ prefix
- Set customer token cookie path to "/" for cross-route compatibility
- Fix double storefront in URLs: replace {{ base_url }}storefront/ with {{ base_url }}
across all 24 storefront templates
- Fix auth error redirect to include platform prefix and use store_code
- Update seed script to output correct storefront login URLs
- Add 20 new unit tests covering all fixes; fix 9 pre-existing test failures
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,6 +132,7 @@ class TestLanguageDispatchStore:
|
||||
mock_resolve.assert_called_once_with(
|
||||
user_preferred="de",
|
||||
store_dashboard="fr",
|
||||
cookie_language=None,
|
||||
)
|
||||
assert request.state.language == "de"
|
||||
|
||||
@@ -154,6 +155,7 @@ class TestLanguageDispatchStore:
|
||||
mock_resolve.assert_called_once_with(
|
||||
user_preferred=None,
|
||||
store_dashboard=None,
|
||||
cookie_language=None,
|
||||
)
|
||||
|
||||
|
||||
@@ -356,6 +358,7 @@ class TestLanguageHelpers:
|
||||
max_age=60 * 60 * 24 * 365,
|
||||
httponly=False,
|
||||
samesite="lax",
|
||||
path="/",
|
||||
)
|
||||
assert result is response
|
||||
|
||||
@@ -372,7 +375,7 @@ class TestLanguageHelpers:
|
||||
response = Mock(spec=Response)
|
||||
result = delete_language_cookie(response)
|
||||
|
||||
response.delete_cookie.assert_called_once_with(key="lang")
|
||||
response.delete_cookie.assert_called_once_with(key="lang", path="/")
|
||||
assert result is response
|
||||
|
||||
def test_get_user_language_from_token_with_pref(self):
|
||||
|
||||
Reference in New Issue
Block a user