~fkooman/vpn-user-portal

cd75d5b88bc20dae74a202fb63377b98c0d27b4e — François Kooman 2 months ago e607b18
implement delete_connection Admin API call

References: https://todo.sr.ht/~eduvpn/server/178
1 files changed, 18 insertions(+), 0 deletions(-)

M src/Http/AdminApiModule.php
M src/Http/AdminApiModule.php => src/Http/AdminApiModule.php +18 -0
@@ 186,6 186,24 @@ class AdminApiModule implements ServiceModuleInterface
                }
            }
        );

        $service->post(
            '/v1/delete_connection',
            function (Request $request, UserInfo $userInfo): Response {
                try {
                    $userId = $request->requirePostParameter('user_id', fn(string $s) => Validator::userId($s));
                    if (null === $this->storage->userInfo($userId)) {
                        throw new HttpException('user does not exist', 400);
                    }
                    $connectionId = $request->requirePostParameter('connection_id', fn(string $s) => Validator::connectionId($s));
                    $this->connectionManager->disconnectByConnectionId($userId, $connectionId);

                    return new Response(null, [], 204);
                } catch (ConnectionManagerException $e) {
                    throw new HttpException(sprintf('/v1/delete_connection failed: %s', $e->getMessage()), 500);
                }
            }
        );
    }

    /**