Move all domain folders from src/AKSRT/{Domain} to src/{Domain}; remap
Composer PSR-4 "AKSRT\\": "src/"; update audit script + README + ADR
paths; remove dead tools/build-psr4-map.php (scanned deleted inc/classes).
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Admin REST handlers for identity provider configuration.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
namespace AKSRT\Admin;
|
|
|
|
use AKSRT\Settings\IdentityAdmin;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
trait UserControllerIdentitySettings {
|
|
public function get_identity_settings(): \WP_REST_Response {
|
|
return $this->success([
|
|
'data' => $this->identity_settings_response(IdentityAdmin::read()),
|
|
]);
|
|
}
|
|
|
|
public function update_identity_settings(\WP_REST_Request $request): \WP_REST_Response {
|
|
$settings = IdentityAdmin::update($this->get_json_params($request));
|
|
|
|
return $this->success([
|
|
'message' => __('身份认证服务商配置已保存', 'aksrt'),
|
|
'data' => $this->identity_settings_response($settings),
|
|
]);
|
|
}
|
|
|
|
public function test_identity_settings(\WP_REST_Request $request): \WP_REST_Response {
|
|
$params = $this->get_json_params($request);
|
|
$provider = sanitize_key((string) ($params['provider'] ?? ''));
|
|
$result = IdentityAdmin::test($provider);
|
|
|
|
if (empty($result['success'])) {
|
|
return $this->error((string) ($result['message'] ?? __('配置检查失败', 'aksrt')), 422);
|
|
}
|
|
|
|
return $this->success([
|
|
'message' => (string) $result['message'],
|
|
'data' => ['provider' => $provider, 'configured' => true],
|
|
]);
|
|
}
|
|
|
|
private function identity_settings_response(array $settings): array {
|
|
$settings['callback_url'] = [
|
|
'aliyun' => rest_url(self::API_NAMESPACE . '/identity/callback/aliyun'),
|
|
'tencent' => rest_url(self::API_NAMESPACE . '/identity/callback/tencent'),
|
|
];
|
|
return $settings;
|
|
}
|
|
}
|