mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-25 08:26:06 +08:00
增加登录设备展示
This commit is contained in:
parent
381c32a3b4
commit
9ab08a71c0
|
@ -50,6 +50,7 @@ export default class AuthService {
|
||||||
twoFactorActivated,
|
twoFactorActivated,
|
||||||
twoFactorActived,
|
twoFactorActived,
|
||||||
tokens = {},
|
tokens = {},
|
||||||
|
platform,
|
||||||
} = content;
|
} = content;
|
||||||
// patch old field
|
// patch old field
|
||||||
twoFactorActivated = twoFactorActivated || twoFactorActived;
|
twoFactorActivated = twoFactorActivated || twoFactorActived;
|
||||||
|
@ -103,22 +104,29 @@ export default class AuthService {
|
||||||
retries: 0,
|
retries: 0,
|
||||||
lastip: ip,
|
lastip: ip,
|
||||||
lastaddr: address,
|
lastaddr: address,
|
||||||
|
platform: req.platform,
|
||||||
isTwoFactorChecking: false,
|
isTwoFactorChecking: false,
|
||||||
});
|
});
|
||||||
await this.notificationService.notify(
|
await this.notificationService.notify(
|
||||||
'登陆通知',
|
'登陆通知',
|
||||||
`你于${new Date(
|
`你于${new Date(timestamp).toLocaleString()}在 ${address} ${
|
||||||
timestamp,
|
req.platform
|
||||||
).toLocaleString()}在 ${address} 登陆成功,ip地址 ${ip}`,
|
}端 登陆成功,ip地址 ${ip}`,
|
||||||
);
|
);
|
||||||
await this.getLoginLog();
|
await this.getLoginLog();
|
||||||
await this.insertDb({
|
await this.insertDb({
|
||||||
type: AuthDataType.loginLog,
|
type: AuthDataType.loginLog,
|
||||||
info: { timestamp, address, ip, status: LoginStatus.success },
|
info: {
|
||||||
|
timestamp,
|
||||||
|
address,
|
||||||
|
ip,
|
||||||
|
platform: req.platform,
|
||||||
|
status: LoginStatus.success,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: { token, lastip, lastaddr, lastlogon, retries },
|
data: { token, lastip, lastaddr, lastlogon, retries, platform },
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.updateAuthInfo(content, {
|
this.updateAuthInfo(content, {
|
||||||
|
@ -126,17 +134,24 @@ export default class AuthService {
|
||||||
lastlogon: timestamp,
|
lastlogon: timestamp,
|
||||||
lastip: ip,
|
lastip: ip,
|
||||||
lastaddr: address,
|
lastaddr: address,
|
||||||
|
platform: req.platform,
|
||||||
});
|
});
|
||||||
await this.notificationService.notify(
|
await this.notificationService.notify(
|
||||||
'登陆通知',
|
'登陆通知',
|
||||||
`你于${new Date(
|
`你于${new Date(timestamp).toLocaleString()}在 ${address} ${
|
||||||
timestamp,
|
req.platform
|
||||||
).toLocaleString()}在 ${address} 登陆失败,ip地址 ${ip}`,
|
}端 登陆失败,ip地址 ${ip}`,
|
||||||
);
|
);
|
||||||
await this.getLoginLog();
|
await this.getLoginLog();
|
||||||
await this.insertDb({
|
await this.insertDb({
|
||||||
type: AuthDataType.loginLog,
|
type: AuthDataType.loginLog,
|
||||||
info: { timestamp, address, ip, status: LoginStatus.fail },
|
info: {
|
||||||
|
timestamp,
|
||||||
|
address,
|
||||||
|
ip,
|
||||||
|
platform: req.platform,
|
||||||
|
status: LoginStatus.fail,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return { code: 400, message: config.authError };
|
return { code: 400, message: config.authError };
|
||||||
}
|
}
|
||||||
|
@ -243,6 +258,7 @@ export default class AuthService {
|
||||||
this.updateAuthInfo(authInfo, {
|
this.updateAuthInfo(authInfo, {
|
||||||
lastip: ip,
|
lastip: ip,
|
||||||
lastaddr: address,
|
lastaddr: address,
|
||||||
|
platform: req.platform,
|
||||||
});
|
});
|
||||||
return { code: 430, message: '验证失败' };
|
return { code: 430, message: '验证失败' };
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,14 @@ const Login = () => {
|
||||||
|
|
||||||
const checkResponse = (data: any) => {
|
const checkResponse = (data: any) => {
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
const { token, lastip, lastaddr, lastlogon, retries = 0 } = data.data;
|
const {
|
||||||
|
token,
|
||||||
|
lastip,
|
||||||
|
lastaddr,
|
||||||
|
lastlogon,
|
||||||
|
retries = 0,
|
||||||
|
platform,
|
||||||
|
} = data.data;
|
||||||
localStorage.setItem(config.authKey, token);
|
localStorage.setItem(config.authKey, token);
|
||||||
notification.success({
|
notification.success({
|
||||||
message: '登录成功!',
|
message: '登录成功!',
|
||||||
|
@ -89,6 +96,7 @@ const Login = () => {
|
||||||
</div>
|
</div>
|
||||||
<div>上次登录地点:{lastaddr || '-'}</div>
|
<div>上次登录地点:{lastaddr || '-'}</div>
|
||||||
<div>上次登录IP:{lastip || '-'}</div>
|
<div>上次登录IP:{lastip || '-'}</div>
|
||||||
|
<div>上次登录设备:{platform || '-'}</div>
|
||||||
<div>上次登录状态:{retries > 0 ? `失败${retries}次` : '成功'}</div>
|
<div>上次登录状态:{retries > 0 ? `失败${retries}次` : '成功'}</div>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
|
|
|
@ -45,6 +45,12 @@ const columns = [
|
||||||
key: 'ip',
|
key: 'ip',
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '登陆设备',
|
||||||
|
dataIndex: 'platform',
|
||||||
|
key: 'platform',
|
||||||
|
align: 'center' as const,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '登陆状态',
|
title: '登陆状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user