mirror of
https://github.com/certd/certd.git
synced 2026-05-16 05:07:32 +08:00
perf: 支持oidc单点登录
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import {In, MoreThan, Not, Repository} from 'typeorm';
|
||||
import {EntityManager, In, MoreThan, Not, Repository} from 'typeorm';
|
||||
import { UserEntity } from '../entity/user.js';
|
||||
import * as _ from 'lodash-es';
|
||||
import { BaseService, CommonException, Constants, FileService, SysInstallInfo, SysSettingsService } from '@certd/lib-server';
|
||||
@@ -171,7 +171,7 @@ export class UserService extends BaseService<UserEntity> {
|
||||
return await this.roleService.getPermissionByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
async register(type: string, user: UserEntity) {
|
||||
async register(type: string, user: UserEntity,withTx?:(tx: EntityManager)=>Promise<void>) {
|
||||
if (!user.password) {
|
||||
user.password = simpleNanoId();
|
||||
}
|
||||
@@ -227,6 +227,10 @@ export class UserService extends BaseService<UserEntity> {
|
||||
newUser = await txManager.save(newUser);
|
||||
const userRole: UserRoleEntity = UserRoleEntity.of(newUser.id, Constants.role.defaultUser);
|
||||
await txManager.save(userRole);
|
||||
|
||||
if(withTx) {
|
||||
await withTx(txManager);
|
||||
}
|
||||
});
|
||||
|
||||
delete newUser.password;
|
||||
|
||||
Reference in New Issue
Block a user