Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ sync-exclude.txt
copy-dist-exclude.txt
tmpclaude-*

# Cursor
.cursor/

# PHPStan (local config with machine-specific paths)
phpstan.neon
phpstan-baseline.neon
22 changes: 0 additions & 22 deletions assets/components/minishop3/js/web/core/TokenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,6 @@ class TokenManager {
}
}

/**
* Refresh existing token (extend lifetime)
*
* @returns {Promise<void>}
*/
async refreshToken () {
if (!this.apiClient) {
console.error('TokenManager: ApiClient not set')
return
}

try {
const response = await this.apiClient.post('/customer/token/update')

if (response.success) {
this.tokenInitialized = true
}
} catch (error) {
console.error('TokenManager: Error refreshing token', error)
}
}

/**
* Remove legacy localStorage data
*/
Expand Down
4 changes: 0 additions & 4 deletions core/components/minishop3/config/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@
}
});

$router->post('/token/refresh', function($params) use ($modx) {
return Response::success(['message' => 'Customer token/refresh endpoint - not implemented yet']);
});

$router->group('/addresses', function($router) use ($modx) {
$router->get('', function($params) use ($modx) {
$controller = new \MiniShop3\Controllers\Api\Web\CustomerAddressController($modx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class TokenMiddleware implements MiddlewareInterface
'/api/v1/product/get',
'/api/v1/product/list',
'/api/v1/customer/token/get',
'/api/v1/customer/token/refresh',
'/api/v1/health',
];

Expand Down
41 changes: 41 additions & 0 deletions core/components/minishop3/tests/TokenRefreshRouteRemovedTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* Контракт #334: POST /customer/token/refresh не зарегистрирован
* и не отдаёт ложный success-stub.
*
* Запуск: php tests/TokenRefreshRouteRemovedTest.php
*/

declare(strict_types=1);

$fail = static function (string $message): never {
fwrite(STDERR, "FAIL: {$message}\n");
exit(1);
};

$base = dirname(__DIR__);
$webRoutes = file_get_contents($base . '/config/routes/web.php');
if ($webRoutes === false) {
$fail('cannot read config/routes/web.php');
}

$tokenMiddleware = file_get_contents($base . '/src/Middleware/TokenMiddleware.php');
if ($tokenMiddleware === false) {
$fail('cannot read src/Middleware/TokenMiddleware.php');
}

if (str_contains($webRoutes, 'token/refresh')) {
$fail('config/routes/web.php must not register token/refresh');
}

if (str_contains($tokenMiddleware, 'token/refresh')) {
$fail('TokenMiddleware publicRoutes must not include token/refresh');
}

if (str_contains($webRoutes, 'Customer token/refresh endpoint - not implemented yet')) {
$fail('web.php must not contain the customer token/refresh success stub');
}

fwrite(STDOUT, "OK TokenRefreshRouteRemovedTest\n");
exit(0);