修复重置用户名失败

This commit is contained in:
whyour 2025-05-15 01:12:01 +08:00
parent c3072e7712
commit 05db2b1df8

View File

@ -21,6 +21,8 @@ import dayjs from 'dayjs';
import IP2Region from 'ip2region'; import IP2Region from 'ip2region';
import requestIp from 'request-ip'; import requestIp from 'request-ip';
import uniq from 'lodash/uniq'; import uniq from 'lodash/uniq';
import pickBy from 'lodash/pickBy';
import isNil from 'lodash/isNil';
import { shareStore } from '../shared/store'; import { shareStore } from '../shared/store';
@Service() @Service()
@ -365,11 +367,16 @@ export default class UserService {
public async resetAuthInfo(info: Partial<AuthInfo>) { public async resetAuthInfo(info: Partial<AuthInfo>) {
const { retries, twoFactorActivated, password, username } = info; const { retries, twoFactorActivated, password, username } = info;
const authInfo = await this.getAuthInfo(); const authInfo = await this.getAuthInfo();
await this.updateAuthInfo(authInfo, { const payload = pickBy(
retries, {
twoFactorActivated, retries,
password, twoFactorActivated,
username password,
}); username,
},
(x) => !isNil(x),
);
await this.updateAuthInfo(authInfo, payload);
} }
} }