返回提交历史
Modified
src/controllers/api/loginController.ts
+11
-6
Modified
src/models/loginModel.ts
+4
-6
Modified
src/types/loginTypes.ts
+2
-2
XFEstudio/XFESpaceNinjaServer
chore: hardcode some fields in login response (#3541)
This is a relatively soft change as we can always just add the defaults again in the future, should we need them, but there's no point using MongoDB to store constant/unused data right now. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3541 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
d7d5922c
代码差异
3 个文件
+17
-14
@@ -120,6 +120,13 @@ export const loginController: RequestHandler = async (request, response) => {
120
120
account.LastLogin = new Date();
121
121
account.LastPlatform = isAndroid ? Platform.Android : Platform.Windows;
122
122
account.Dropped = undefined;
123
124
// These fields used to be set by default but are really not needed
125
account.ConsentNeeded = undefined;
126
account.TrackedSettings = undefined;
127
account.ForceLogoutVersion = undefined;
128
account.CrossPlatformAllowed = undefined;
129
123
130
await account.save();
124
131
125
132
handleNonceInvalidation(account._id.toString());
@@ -152,8 +159,6 @@ const createLoginResponse = (request: Request, account: IDatabaseAccountJson, bu
152
159
const resp: ILoginResponse = {
153
160
id: account.id,
154
161
DisplayName: account.DisplayName,
155
AmazonAuthToken: account.AmazonAuthToken,
156
AmazonRefreshToken: account.AmazonRefreshToken,
157
162
Nonce: account.Nonce,
158
163
BuildLabel: buildLabel
159
164
};
@@ -173,11 +178,11 @@ const createLoginResponse = (request: Request, account: IDatabaseAccountJson, bu
173
178
resp.IRC = [(config.ircAddress || "%THIS_MACHINE%").split("%THIS_MACHINE%").join(myAddress)];
174
179
}
175
180
if (version_compare(buildLabel, gameToBuildVersion["24.0.0"]) >= 0) {
176
resp.ConsentNeeded = account.ConsentNeeded;
177
resp.TrackedSettings = account.TrackedSettings;
181
resp.ConsentNeeded = false;
182
resp.TrackedSettings = [];
178
183
}
179
184
if (version_compare(buildLabel, gameToBuildVersion["25.7.0"]) >= 0) {
180
resp.ForceLogoutVersion = account.ForceLogoutVersion;
185
resp.ForceLogoutVersion = 0;
181
186
}
182
187
if (version_compare(buildLabel, gameToBuildVersion["26.0.0"]) >= 0) {
183
188
resp.Groups = [];
@@ -189,7 +194,7 @@ const createLoginResponse = (request: Request, account: IDatabaseAccountJson, bu
189
194
resp.ClientType = account.ClientType;
190
195
}
191
196
if (version_compare(buildLabel, gameToBuildVersion["32.0.0"]) >= 0) {
192
resp.CrossPlatformAllowed = account.CrossPlatformAllowed;
197
resp.CrossPlatformAllowed = true;
193
198
resp.HUB = `${myUrlBase}/api/`;
194
199
195
200
// The MatchmakingBuildId is a 64-bit integer represented as a decimal string. On live, the value is seemingly random per build, but really any value that is different across builds should work.
@@ -16,13 +16,11 @@ const databaseAccountSchema = new Schema<IDatabaseAccountJson>(
16
16
DisplayName: { type: String, required: true, unique: true, maxLength: MAX_NAME_LENGTH },
17
17
CountryCode: { type: String, default: "" },
18
18
ClientType: { type: String },
19
CrossPlatformAllowed: { type: Boolean, default: true },
20
ForceLogoutVersion: { type: Number, default: 0 },
21
AmazonAuthToken: { type: String },
22
AmazonRefreshToken: { type: String },
19
CrossPlatformAllowed: Boolean,
20
ForceLogoutVersion: Number,
23
21
GoogleTokenId: { type: String },
24
ConsentNeeded: { type: Boolean, default: false },
25
TrackedSettings: { type: [String], default: [] },
22
ConsentNeeded: Boolean,
23
TrackedSettings: { type: [String], default: undefined },
26
24
Nonce: { type: Number, default: 0 },
27
25
BuildLabel: String,
28
26
LastLogin: { type: Date, default: 0 },
@@ -16,8 +16,6 @@ export interface IAccountAndLoginResponseCommons {
16
16
CrossPlatformAllowed?: boolean;
17
17
ForceLogoutVersion?: number;
18
18
GoogleTokenId?: string;
19
AmazonAuthToken?: string;
20
AmazonRefreshToken?: string;
21
19
ConsentNeeded?: boolean;
22
20
TrackedSettings?: string[];
23
21
Nonce: number;
@@ -74,6 +72,8 @@ export interface ILoginResponse extends IAccountAndLoginResponseCommons {
74
72
HUB?: string;
75
73
NatHash?: string;
76
74
SteamId?: string;
75
AmazonAuthToken?: string;
76
AmazonRefreshToken?: string;
77
77
}
78
78
79
79
export interface IGroup {