From 460deed3ed2631363ca2185c1e98e0f0c8730752 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Tue, 6 May 2025 02:29:03 -0700 Subject: [PATCH] fix: login failure on U16 (#1991) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1991 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/api/loginController.ts | 9 ++++++--- src/types/loginTypes.ts | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/controllers/api/loginController.ts b/src/controllers/api/loginController.ts index de8b7951..8f368a67 100644 --- a/src/controllers/api/loginController.ts +++ b/src/controllers/api/loginController.ts @@ -41,7 +41,7 @@ export const loginController: RequestHandler = async (request, response) => { email: loginRequest.email, password: loginRequest.password, DisplayName: name, - CountryCode: loginRequest.lang.toUpperCase(), + CountryCode: loginRequest.lang?.toUpperCase() ?? "EN", ClientType: loginRequest.ClientType == "webui-register" ? "webui" : loginRequest.ClientType, CrossPlatformAllowed: true, ForceLogoutVersion: 0, @@ -91,7 +91,7 @@ export const loginController: RequestHandler = async (request, response) => { account.ClientType = loginRequest.ClientType; account.Nonce = nonce; - account.CountryCode = loginRequest.lang.toUpperCase(); + account.CountryCode = loginRequest.lang?.toUpperCase() ?? "EN"; account.BuildLabel = buildLabel; } await account.save(); @@ -107,10 +107,13 @@ const createLoginResponse = (myAddress: string, account: IDatabaseAccountJson, b AmazonAuthToken: account.AmazonAuthToken, AmazonRefreshToken: account.AmazonRefreshToken, Nonce: account.Nonce, - IRC: config.myIrcAddresses ?? [myAddress], NRS: config.NRS, BuildLabel: buildLabel }; + if (version_compare(buildLabel, "2015.05.14.16.29") >= 0) { + // U17 and up + resp.IRC = config.myIrcAddresses ?? [myAddress]; + } if (version_compare(buildLabel, "2018.11.08.14.45") >= 0) { // U24 and up resp.ConsentNeeded = account.ConsentNeeded; diff --git a/src/types/loginTypes.ts b/src/types/loginTypes.ts index 8bbee787..5a7f9e46 100644 --- a/src/types/loginTypes.ts +++ b/src/types/loginTypes.ts @@ -35,11 +35,11 @@ export interface ILoginRequest { email: string; password: string; time: number; - s: string; - lang: string; + s?: string; + lang?: string; date: number; - ClientType: string; - PS: string; + ClientType?: string; + PS?: string; kick?: boolean; } @@ -51,7 +51,7 @@ export interface ILoginResponse extends IAccountAndLoginResponseCommons { platformCDNs?: string[]; NRS?: string[]; DTLS?: number; - IRC: string[]; + IRC?: string[]; HUB?: string; }