mirror of
https://github.com/certd/certd.git
synced 2026-05-15 20:47:31 +08:00
perf: 增加系统设置,可以关闭自助注册功能
This commit is contained in:
@@ -10,6 +10,7 @@ import { BaseController } from '../../../basic/base-controller';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
import { UserService } from '../../authority/service/user-service';
|
||||
import { UserEntity } from '../../authority/entity/user';
|
||||
import { SysSettingsService } from '../../system/service/sys-settings-service';
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -18,11 +19,19 @@ import { UserEntity } from '../../authority/entity/user';
|
||||
export class RegisterController extends BaseController {
|
||||
@Inject()
|
||||
userService: UserService;
|
||||
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Post('/register', { summary: Constants.per.guest })
|
||||
public async register(
|
||||
@Body(ALL)
|
||||
user: UserEntity
|
||||
) {
|
||||
const sysPublicSettings = await this.sysSettingsService.getPublicSettings();
|
||||
if (sysPublicSettings.registerEnabled === false) {
|
||||
throw new Error('当前站点已禁止自助注册功能');
|
||||
}
|
||||
const newUser = await this.userService.register(user);
|
||||
return this.ok(newUser);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user