mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复登录重试判断
This commit is contained in:
parent
622037ee98
commit
8c355b6159
|
@ -39,6 +39,17 @@ export default class AuthService {
|
||||||
) {
|
) {
|
||||||
return this.initAuthInfo();
|
return this.initAuthInfo();
|
||||||
}
|
}
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
if (username === cUsername && password === cPassword) {
|
if (username === cUsername && password === cPassword) {
|
||||||
const data = createRandomString(50, 100);
|
const data = createRandomString(50, 100);
|
||||||
let token = jwt.sign({ data }, config.secret as any, {
|
let token = jwt.sign({ data }, config.secret as any, {
|
||||||
|
@ -68,20 +79,6 @@ export default class AuthService {
|
||||||
lastaddr: 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 };
|
return { code: 400, message: config.authError };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -107,6 +107,7 @@ const Login = () => {
|
||||||
<Countdown
|
<Countdown
|
||||||
valueStyle={{ color: 'rgba(232, 230, 227, 0.25)' }}
|
valueStyle={{ color: 'rgba(232, 230, 227, 0.25)' }}
|
||||||
className="inline-countdown"
|
className="inline-countdown"
|
||||||
|
onFinish={() => setWaitTime(null)}
|
||||||
format="ss"
|
format="ss"
|
||||||
value={Date.now() + 1000 * waitTime}
|
value={Date.now() + 1000 * waitTime}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user