返回提交历史
Modified
src/controllers/custom/changeEmailController.ts
+1
-1
Modified
src/controllers/custom/changePasswordController.ts
+1
-1
Modified
static/webui/script.js
+8
-4
XFEstudio/XFESpaceNinjaServer
fix(webui): remove hardcoded strings when changing password or email (#3740)
Closes #3738 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3740 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
8e8788f3
代码差异
3 个文件
+10
-6
@@ -24,7 +24,7 @@ export const changeEmailController: RequestHandler = async (req, res) => {
24
24
return;
25
25
}
26
26
if (newEmail === account.email) {
27
res.status(400).send("That is already your email").end();
27
res.send("noop").end();
28
28
return;
29
29
}
30
30
const taken = await Account.findOne({ email: newEmail });
@@ -22,7 +22,7 @@ export const changePasswordController: RequestHandler = async (req, res) => {
22
22
return;
23
23
}
24
24
if (body.currentPassword === body.newPassword) {
25
res.status(400).send("New password must differ from the current one").end();
25
res.send("noop").end();
26
26
return;
27
27
}
28
28
account.password = body.newPassword;
@@ -280,11 +280,13 @@ function changeAccountPassword() {
280
280
}).then(res => {
281
281
if (res.status == 200) {
282
282
localStorage.setItem("password", nw);
283
toast(loc("settings_passwordSuccess"));
283
res.text().then(text => {
284
toast(loc(text == "noop" ? "code_nothingToDo" : "settings_passwordSuccess"));
285
});
284
286
} else if (res.status == 403) {
285
287
toast(loc("settings_wrongPassword"));
286
288
} else {
287
res.text().then(t => toast(t || loc("settings_changeFailed")));
289
toast(loc("settings_changeFailed"));
288
290
}
289
291
});
290
292
});
@@ -327,13 +329,15 @@ function changeAccountEmail() {
327
329
}).then(res => {
328
330
if (res.status == 200) {
329
331
localStorage.setItem("email", newEmail);
330
toast(loc("settings_emailSuccess"));
332
res.text().then(text => {
333
toast(loc(text == "noop" ? "code_nothingToDo" : "settings_emailSuccess"));
334
});
331
335
} else if (res.status == 403) {
332
336
toast(loc("settings_wrongPassword"));
333
337
} else if (res.status == 409) {
334
338
promptAndSend(newEmail);
335
339
} else {
336
res.text().then(t => toast(t || loc("settings_changeFailed")));
340
toast(loc("settings_changeFailed"));
337
341
}
338
342
});
339
343
});