登录增加错误延迟提醒

This commit is contained in:
hanhh
2021-08-22 12:28:45 +08:00
parent 54bb13aad0
commit 622037ee98
4 changed files with 63 additions and 23 deletions
+15 -12
View File
@@ -58,17 +58,6 @@ export default class AuthService {
);
return { code: 200, data: { token, lastip, lastaddr, lastlogon } };
} else {
if (
retries > 2 &&
Date.now() - lastlogon < Math.pow(3, retries) * 1000
) {
return {
code: 400,
message: `失败次数过多,请${Math.round(
(Math.pow(3, retries) * 1000 - Date.now() + lastlogon) / 1000,
)}秒后重试`,
};
}
fs.writeFileSync(
config.authConfigFile,
JSON.stringify({
@@ -76,9 +65,23 @@ export default class AuthService {
retries: retries + 1,
lastlogon: timestamp,
ip,
address,
lastaddr: address,
}),
);
if (
retries > 2 &&
Date.now() - lastlogon < Math.pow(3, retries) * 1000
) {
return {
code: 410,
message: `失败次数过多,请${Math.round(
(Math.pow(3, retries) * 1000 - Date.now() + lastlogon) / 1000,
)}秒后重试`,
data: Math.round(
(Math.pow(3, retries) * 1000 - Date.now() + lastlogon) / 1000,
),
};
}
return { code: 400, message: config.authError };
}
} else {