From 05db2b1df8baec659ccdb12543907777b98c2124 Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 15 May 2025 01:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E7=BD=AE=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/user.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/back/services/user.ts b/back/services/user.ts index f5909ee3..604b3c82 100644 --- a/back/services/user.ts +++ b/back/services/user.ts @@ -21,6 +21,8 @@ import dayjs from 'dayjs'; import IP2Region from 'ip2region'; import requestIp from 'request-ip'; import uniq from 'lodash/uniq'; +import pickBy from 'lodash/pickBy'; +import isNil from 'lodash/isNil'; import { shareStore } from '../shared/store'; @Service() @@ -365,11 +367,16 @@ export default class UserService { public async resetAuthInfo(info: Partial) { const { retries, twoFactorActivated, password, username } = info; const authInfo = await this.getAuthInfo(); - await this.updateAuthInfo(authInfo, { - retries, - twoFactorActivated, - password, - username - }); + const payload = pickBy( + { + retries, + twoFactorActivated, + password, + username, + }, + (x) => !isNil(x), + ); + + await this.updateAuthInfo(authInfo, payload); } }