- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks - Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists - Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services - Add Microsoft OIDC SSO, API token management, and user lifecycle features - Add swagger-ui vendor integration and OpenAPI spec - Add production Docker setup and bin/ scripts - Update composer dependencies, config, templates, and frontend assets throughout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
use MintyPHP\Support\Guard;
|
|
use MintyPHP\Support\Flash;
|
|
use MintyPHP\Router;
|
|
use MintyPHP\Service\Access\PermissionService;
|
|
use MintyPHP\Service\Auth\ApiTokenService;
|
|
use MintyPHP\Service\User\UserService;
|
|
|
|
Guard::requireLogin();
|
|
Guard::requirePermissionOrForbidden(PermissionService::API_TOKENS_MANAGE);
|
|
|
|
$uuid = trim((string) ($id ?? ''));
|
|
$user = $uuid !== '' ? UserService::findByUuid($uuid) : null;
|
|
if (!$user) {
|
|
Router::redirect('admin/users');
|
|
}
|
|
|
|
$userId = (int) ($user['id'] ?? 0);
|
|
$currentUserId = (int) ($_SESSION['user']['id'] ?? 0);
|
|
$name = trim((string) ($_POST['token_name'] ?? ''));
|
|
|
|
if ($name === '') {
|
|
Flash::error(t('Token name is required'), "admin/users/edit/{$uuid}", 'api_token_error');
|
|
Router::redirect("admin/users/edit/{$uuid}");
|
|
}
|
|
|
|
$result = ApiTokenService::create($userId, $name, null, null, $currentUserId);
|
|
|
|
if ($result['ok'] ?? false) {
|
|
$_SESSION['api_token_created'] = ['token' => $result['token'], 'uuid' => $uuid];
|
|
Flash::success(t('API token created. Copy it now — it will not be shown again.'), "admin/users/edit/{$uuid}", 'api_token_created');
|
|
} else {
|
|
$error = $result['error'] ?? 'create_failed';
|
|
Flash::error(t('Could not create API token: %s', $error), "admin/users/edit/{$uuid}", 'api_token_error');
|
|
}
|
|
|
|
Router::redirect("admin/users/edit/{$uuid}");
|