fix(web-api): bind API token on email verify#441
Open
Ibochkarev wants to merge 1 commit into
Open
Conversation
Email verification wrote legacy msCustomer.token into PHP session while the msCustomerToken cookie stayed guest, causing split-brain auth. Extract establishApiSession() (same path as login) and use it from verify, login, and register so cookie, session, and API token stay aligned. Closes #411
Ibochkarev
force-pushed
the
fix/issue-411-email-verify-api-token
branch
from
July 24, 2026 02:17
5217b16 to
28c9b28
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
После
GET /api/v1/customer/email/verifyв PHP session попадалиcustomer_idи legacymsCustomer.token, а cookiemsCustomerTokenоставался гостевым. Profile/addresses шли через session short-circuit, корзина и заказ — через guest API token (split-brain).Логика привязки API-сессии вынесена в
AuthManager::establishApiSession()(reuse гостевого токена из cookie → bindcustomer_id, extend TTL,bindDraftToCustomer; иначе новый токен + cookie). Метод используют verify, login и register. При сбое auto-login JSON возвращает success сtoken: null(email уже verified), как html-redirect без сессии.Тип изменений
Связанные Issues
Closes #411
Как это было протестировано?
Локальный гейт (без MODX/MySQL):
Конфигурация тестирования:
Скриншоты (если применимо)
n/a
Чеклист
npm run lint:ciдля Vue) — Vue не затронутДополнительные заметки
format=jsonтеперь возвращаетtoken/expires_atкак login processor — нужно SPA-клиентам после verify.ms3_tokenна verify — те же trade-off, что у login/register; ротация токена на verify — возможный follow-up ([Bug] Checkout: захват msCustomer — token чужого аккаунта по email #369).