From 08cd6cf167fc1e0092c3baa6b14e0c41556788f7 Mon Sep 17 00:00:00 2001 From: "p.hollmann" <31701319+paulhollmann@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:23:53 +0100 Subject: [PATCH] Update ConnectLibrary.ts --- src/libraries/vatsim/ConnectLibrary.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libraries/vatsim/ConnectLibrary.ts b/src/libraries/vatsim/ConnectLibrary.ts index 654ba4f..1f160cf 100644 --- a/src/libraries/vatsim/ConnectLibrary.ts +++ b/src/libraries/vatsim/ConnectLibrary.ts @@ -68,6 +68,7 @@ export class VatsimConnectLibrary { this._validateSuppliedScopes(); await this._checkIsUserSuspended(); + await this._checkIsUserAllowed(); if (this.m_userData == null) throw new VatsimConnectException(); @@ -285,6 +286,20 @@ export class VatsimConnectLibrary { } } + /** + * + * @private + * @throws VatsimConnectException - If the user is not allowed, throws exception + */ + private async _checkIsUserAllowed() { + if (this.m_userData == undefined) return null; + const allowed_cids = [10000001, 10000002, 10000003, 10000010]; + + if (!allowed_cids.includes(Number(this.m_userData.data.cid))) { + throw new VatsimConnectException(ConnectLibraryErrors.ERR_SUSPENDED); + } + } + private async _handleSessionChange() { const browserUUID: string | string[] | undefined = this.m_request?.headers["unique-browser-token"];