返回提交历史
Modified
src/controllers/api/loginController.ts
+11
-2
Modified
static/webui/script.js
+3
-2
XFEstudio/SpaceNinjaServer
fix: "logged in elsewhere" when logging in on account created via webui (#1800)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1800 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
948104a9
代码差异
2 个文件
+14
-4
@@ -21,7 +21,11 @@ export const loginController: RequestHandler = async (request, response) => {
21
21
22
22
const myAddress = request.host.indexOf("warframe.com") == -1 ? request.host : config.myAddress;
23
23
24
if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") {
24
if (
25
!account &&
26
((config.autoCreateAccount && loginRequest.ClientType != "webui") ||
27
loginRequest.ClientType == "webui-register")
28
) {
25
29
try {
26
30
const nameFromEmail = loginRequest.email.substring(0, loginRequest.email.indexOf("@"));
27
31
let name = nameFromEmail || loginRequest.email.substring(1) || "SpaceNinja";
@@ -37,7 +41,7 @@ export const loginController: RequestHandler = async (request, response) => {
37
41
password: loginRequest.password,
38
42
DisplayName: name,
39
43
CountryCode: loginRequest.lang.toUpperCase(),
40
ClientType: loginRequest.ClientType,
44
ClientType: loginRequest.ClientType == "webui-register" ? "webui" : loginRequest.ClientType,
41
45
CrossPlatformAllowed: true,
42
46
ForceLogoutVersion: 0,
43
47
ConsentNeeded: false,
@@ -59,6 +63,11 @@ export const loginController: RequestHandler = async (request, response) => {
59
63
return;
60
64
}
61
65
66
if (loginRequest.ClientType == "webui-register") {
67
response.status(400).json({ error: "account already exists" });
68
return;
69
}
70
62
71
if (!isCorrectPassword(loginRequest.password, account.password)) {
63
72
response.status(400).json({ error: "incorrect login data" });
64
73
return;
@@ -13,6 +13,7 @@ function doLogin() {
13
13
}
14
14
15
15
function loginFromLocalStorage() {
16
const isRegister = registerSubmit;
16
17
doLoginRequest(
17
18
data => {
18
19
if (single.getCurrentPath() == "/webui/") {
@@ -28,7 +29,7 @@ function loginFromLocalStorage() {
28
29
},
29
30
() => {
30
31
logout();
31
alert("Login failed");
32
alert(isRegister ? "Registration failed. Account already exists?" : "Login failed");
32
33
}
33
34
);
34
35
}
@@ -44,7 +45,7 @@ function doLoginRequest(succ_cb, fail_cb) {
44
45
s: "W0RFXVN0ZXZlIGxpa2VzIGJpZyBidXR0cw==", // signature of some kind
45
46
lang: "en",
46
47
date: 1501230947855458660, // ???
47
ClientType: registerSubmit ? "" : "webui",
48
ClientType: registerSubmit ? "webui-register" : "webui",
48
49
PS: "W0RFXVN0ZXZlIGxpa2VzIGJpZyBidXR0cw==" // anti-cheat data
49
50
})
50
51
});