chore: auto-detect 'my address', only use config as fallback
All checks were successful
Build / build (20) (push) Successful in 38s
Build / build (18) (pull_request) Successful in 37s
Build / build (20) (pull_request) Successful in 56s
Build / build (22) (pull_request) Successful in 56s
Build / build (18) (push) Successful in 1m0s
Build / build (22) (push) Successful in 52s

This is useful for LAN usage where we can use localhost on our own machine but have to use 192.168.x.y on other devices.
This commit is contained in:
Sainan 2025-03-08 23:06:41 +01:00
parent 92d53e1c00
commit 709f9bddc9

View File

@ -19,6 +19,8 @@ export const loginController: RequestHandler = async (request, response) => {
? request.query.buildLabel.split(" ").join("+") ? request.query.buildLabel.split(" ").join("+")
: buildConfig.buildLabel; : buildConfig.buildLabel;
const myAddress = request.host.indexOf("warframe.com") == -1 ? request.host : config.myAddress;
if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") { if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") {
try { try {
const nameFromEmail = loginRequest.email.substring(0, loginRequest.email.indexOf("@")); const nameFromEmail = loginRequest.email.substring(0, loginRequest.email.indexOf("@"));
@ -44,7 +46,7 @@ export const loginController: RequestHandler = async (request, response) => {
LatestEventMessageDate: new Date(0) LatestEventMessageDate: new Date(0)
}); });
logger.debug("created new account"); logger.debug("created new account");
response.json(createLoginResponse(newAccount, buildLabel)); response.json(createLoginResponse(myAddress, newAccount, buildLabel));
return; return;
} catch (error: unknown) { } catch (error: unknown) {
if (error instanceof Error) { if (error instanceof Error) {
@ -67,10 +69,10 @@ export const loginController: RequestHandler = async (request, response) => {
} }
await account.save(); await account.save();
response.json(createLoginResponse(account.toJSON(), buildLabel)); response.json(createLoginResponse(myAddress, account.toJSON(), buildLabel));
}; };
const createLoginResponse = (account: IDatabaseAccountJson, buildLabel: string): ILoginResponse => { const createLoginResponse = (myAddress: string, account: IDatabaseAccountJson, buildLabel: string): ILoginResponse => {
return { return {
id: account.id, id: account.id,
DisplayName: account.DisplayName, DisplayName: account.DisplayName,
@ -84,9 +86,9 @@ const createLoginResponse = (account: IDatabaseAccountJson, buildLabel: string):
TrackedSettings: account.TrackedSettings, TrackedSettings: account.TrackedSettings,
Nonce: account.Nonce, Nonce: account.Nonce,
Groups: [], Groups: [],
IRC: config.myIrcAddresses ?? [config.myAddress], IRC: config.myIrcAddresses ?? [myAddress],
platformCDNs: [`https://${config.myAddress}/`], platformCDNs: [`https://${myAddress}/`],
HUB: `https://${config.myAddress}/api/`, HUB: `https://${myAddress}/api/`,
NRS: config.NRS, NRS: config.NRS,
DTLS: 99, DTLS: 99,
BuildLabel: buildLabel, BuildLabel: buildLabel,