新增批量指令提醒&终端登录提醒

This commit is contained in:
chaos-zhu
2024-08-17 16:33:27 +08:00
parent 221f9e06b9
commit e92e2beb4d
5 changed files with 26 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
const jwt = require('jsonwebtoken')
const axios = require('axios')
const { getNetIPInfo, readKey, writeKey, RSADecryptSync, AESEncryptSync, SHA1Encrypt, getNotifySwByType } = require('../utils')
const { getNetIPInfo, readKey, writeKey, RSADecryptSync, AESEncryptSync, SHA1Encrypt } = require('../utils')
const { asyncSendNotice } = require('../utils/notify')
const getpublicKey = async ({ res }) => {
@@ -26,7 +26,7 @@ const login = async ({ res, request }) => {
if (loginErrCount >= allowErrCount) {
const { ip, country, city } = await getNetIPInfo(clientIp)
// 异步发送通知&禁止登录
asyncSendNotice('err_login', 'EasyNode登录错误提醒', `错误登录次数: ${ loginErrTotal }<br/>地点:${ country + city }<br/>IP: ${ ip }`)
asyncSendNotice('err_login', '登录错误提醒', `错误登录次数: ${ loginErrTotal }<br/>地点:${ country + city }<br/>IP: ${ ip }`)
forbidLogin = true
loginErrCount = 0
@@ -82,7 +82,7 @@ const beforeLoginHandler = async (clientIp, jwtExpires) => {
consola.info('登录成功:', new Date(), { ip, country, city })
// 邮件登录通知
asyncSendNotice('login', 'EasyNode登录提醒', `地点:${ country + city }<br/>IP: ${ ip }`)
asyncSendNotice('login', '登录提醒', `地点:${ country + city }<br/>IP: ${ ip }`)
global.loginRecord.unshift(clientIPInfo)
if (global.loginRecord.length > 10) global.loginRecord = global.loginRecord.slice(0, 10)
@@ -102,7 +102,7 @@ const updatePwd = async ({ res, request }) => {
keyObj.pwd = newPwd
await writeKey(keyObj)
asyncSendNotice('updatePwd', 'EasyNode用户密码修改提醒', `原用户名:${ user }<br/>更新用户名: ${ newLoginName }`)
asyncSendNotice('updatePwd', '用户密码修改提醒', `原用户名:${ user }<br/>更新用户名: ${ newLoginName }`)
res.success({ data: true, msg: 'success' })
}