mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修复登录通知失败造成服务重启
This commit is contained in:
@@ -19,7 +19,7 @@ export class HttpServerService {
|
||||
resolve(this.server);
|
||||
});
|
||||
|
||||
this.server.on('error', (err: Error) => {
|
||||
this.server?.on('error', (err: Error) => {
|
||||
Logger.error('Failed to start HTTP service:', err);
|
||||
reject(err);
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ export default class NotificationService {
|
||||
try {
|
||||
return await notificationModeAction?.call(this);
|
||||
} catch (error: any) {
|
||||
throw error;
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import winston from 'winston';
|
||||
import { createRandomString, getNetIp } from '../config/util';
|
||||
import { createRandomString } from '../config/util';
|
||||
import config from '../config';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { authenticator } from '@otplib/preset-default';
|
||||
@@ -271,7 +271,16 @@ export default class UserService {
|
||||
if (isValid) {
|
||||
return this.login({ username, password }, req, false);
|
||||
} else {
|
||||
const { ip, address } = await getNetIp(req);
|
||||
const ip = requestIp.getClientIp(req) || '';
|
||||
const query = new IP2Region();
|
||||
const ipAddress = query.search(ip);
|
||||
let address = '';
|
||||
if (ipAddress) {
|
||||
const { country, province, city, isp } = ipAddress;
|
||||
address = uniq([country, province, city, isp])
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
}
|
||||
await this.updateAuthInfo(authInfo, {
|
||||
lastip: ip,
|
||||
lastaddr: address,
|
||||
|
||||
Reference in New Issue
Block a user