mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-26 00:46:07 +08:00
两步验证失败增加ip记录
This commit is contained in:
parent
86c3e9a843
commit
2bb55294fc
|
@ -155,7 +155,7 @@ export default class AuthService {
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public twoFactorLogin({ username, password, code }, req) {
|
public async twoFactorLogin({ username, password, code }, req) {
|
||||||
const authInfo = this.getAuthInfo();
|
const authInfo = this.getAuthInfo();
|
||||||
const isValid = authenticator.verify({
|
const isValid = authenticator.verify({
|
||||||
token: code,
|
token: code,
|
||||||
|
@ -165,6 +165,11 @@ export default class AuthService {
|
||||||
this.updateAuthInfo(authInfo, { twoFactorChecked: true });
|
this.updateAuthInfo(authInfo, { twoFactorChecked: true });
|
||||||
return this.login({ username, password }, req);
|
return this.login({ username, password }, req);
|
||||||
} else {
|
} else {
|
||||||
|
const { ip, address } = await getNetIp(req);
|
||||||
|
this.updateAuthInfo(authInfo, {
|
||||||
|
lastip: ip,
|
||||||
|
lastaddr: address,
|
||||||
|
});
|
||||||
return { code: 430, message: '验证失败' };
|
return { code: 430, message: '验证失败' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ export default function (props: any) {
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.data.username) {
|
if (data.data.username) {
|
||||||
setUser(data.data);
|
setUser(data.data);
|
||||||
|
if (props.location.pathname === '/') {
|
||||||
|
history.push('/crontab');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
@ -56,12 +59,6 @@ export default function (props: any) {
|
||||||
document.title = '控制面板';
|
document.title = '控制面板';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (props.location.pathname === '/') {
|
|
||||||
history.push('/crontab');
|
|
||||||
}
|
|
||||||
}, [props.location.pathname]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
|
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
|
||||||
setFetchMethod(window.fetch);
|
setFetchMethod(window.fetch);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user