Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/modules/auth/services/auth-tfa.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class AuthTfaService {

delete other.tfa_pending_secret;
userInfo.other = other;
userInfo.has_totp = true;
user.setUserInfo(userInfo);

await this.userRepository.save(user);
Expand Down Expand Up @@ -163,6 +164,11 @@ export class AuthTfaService {
}

user.tfaSecret = '';


userInfo.has_totp = false;
user.setUserInfo(userInfo);

await this.userRepository.save(user);

return { message: '2FA已禁用' };
Expand Down
4 changes: 4 additions & 0 deletions src/modules/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export class AuthService {
userGroupGuid,
});

const userInfo = user.getUserInfo();
userInfo.has_password = true;
user.setUserInfo(userInfo);

await this.userRepository.save(user);

this.logger.log(`新用户注册成功: ${username}`);
Expand Down
4 changes: 4 additions & 0 deletions src/modules/ldap/ldap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ export class LdapService {
user.oidcSubject = ldapSubject;
user.userGroupGuid = userGroupGuid;

const userInfo = user.getUserInfo();
userInfo.has_password = false;
user.setUserInfo(userInfo);

await this.userRepository.save(user);
this.logger.log(`LDAP 用户已创建: ${finalUsername}`);
return user;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/oidc/services/oidc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,10 @@ export class OidcService {
user.oidcSubject = oidcSubject;
user.userGroupGuid = userGroupGuid;

const userInfo = user.getUserInfo();
userInfo.has_password = false;
user.setUserInfo(userInfo);

await this.userRepository.save(user);
this.logger.log(
`OIDC user created: ${finalUsername} via ${providerName}`,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/user/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export enum UserStatus {
export interface UserInfo {
email_verification?: boolean;
email_alarm_notification?: boolean;
has_password?: boolean;
has_totp?: boolean;
other?: Record<string, any>;
}

Expand Down
17 changes: 17 additions & 0 deletions src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ export class UserService {
user.isAdmin = false;
user.userGroupGuid = userGroupGuid;

const userInfo = user.getUserInfo();
userInfo.has_password = true;
user.setUserInfo(userInfo);

await this.userRepository.save(user);

return { message: '用户创建成功' };
Expand Down Expand Up @@ -234,6 +238,10 @@ export class UserService {
user.isAdmin = false;
user.userGroupGuid = userGroupGuid;

const userInfo = user.getUserInfo();
userInfo.has_password = false;
user.setUserInfo(userInfo);

await this.userRepository.save(user);

// 生成邀请令牌
Expand Down Expand Up @@ -347,6 +355,10 @@ export class UserService {
user.password = await bcrypt.hash(dto.password, 10);
user.status = UserStatus.ACTIVE;

const userInfo = user.getUserInfo();
userInfo.has_password = true;
user.setUserInfo(userInfo);

await this.userRepository.save(user);

// 标记邀请已使用
Expand Down Expand Up @@ -504,6 +516,11 @@ export class UserService {
}

user.password = await bcrypt.hash(dto.new_password, 10);

const userInfo = user.getUserInfo();
userInfo.has_password = true;
user.setUserInfo(userInfo);

await this.userRepository.save(user);

return { message: '密码修改成功' };
Expand Down