From 8f195b964f6db1fe209bfd02bb614526958064ac Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Wed, 8 Sep 2021 12:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=A4=E6=AD=A5=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/auth.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/back/services/auth.ts b/back/services/auth.ts index acb8e917..53fdcf54 100644 --- a/back/services/auth.ts +++ b/back/services/auth.ts @@ -27,6 +27,7 @@ export default class AuthService { password: string; }, req: any, + needTwoFactor = true, ): Promise { if (!fs.existsSync(config.authConfigFile)) { return this.initAuthInfo(); @@ -44,7 +45,6 @@ export default class AuthService { lastip, lastaddr, twoFactorActived, - isTwoFactorChecking, } = content; if ( @@ -69,7 +69,7 @@ export default class AuthService { const { ip, address } = await getNetIp(req); if (username === cUsername && password === cPassword) { - if (twoFactorActived && !isTwoFactorChecking) { + if (twoFactorActived && needTwoFactor) { this.updateAuthInfo(content, { isTwoFactorChecking: true, }); @@ -95,9 +95,9 @@ export default class AuthService { isTwoFactorChecking: false, }); exec( - `notify 登陆通知 你于${new Date( + `notify "登陆通知" "你于${new Date( timestamp, - ).toLocaleString()}在${address}登陆成功,ip地址${ip}`, + ).toLocaleString()}在${address}登陆成功,ip地址${ip}"`, ); await this.getLoginLog(); await this.insertDb({ @@ -116,9 +116,9 @@ export default class AuthService { lastaddr: address, }); exec( - `notify 登陆通知 你于${new Date( + `notify "登陆通知" "你于${new Date( timestamp, - ).toLocaleString()}在${address}登陆失败,ip地址${ip}`, + ).toLocaleString()}在${address}登陆失败,ip地址${ip}"`, ); await this.getLoginLog(); await this.insertDb({ @@ -208,7 +208,7 @@ export default class AuthService { public async twoFactorLogin({ username, password, code }, req) { const authInfo = this.getAuthInfo(); - const { isTwoFactorChecking, retries, twoFactorSecret } = authInfo; + const { isTwoFactorChecking, twoFactorSecret } = authInfo; if (!isTwoFactorChecking) { return { code: 450, message: '未知错误' }; } @@ -217,7 +217,7 @@ export default class AuthService { secret: twoFactorSecret, }); if (isValid) { - return this.login({ username, password }, req); + return this.login({ username, password }, req, false); } else { const { ip, address } = await getNetIp(req); this.updateAuthInfo(authInfo, {