perf: 授权配置支持加密

原本已经添加的授权配置,再次编辑保存即变成加密配置
This commit is contained in:
xiaojunnuo
2024-08-27 13:46:19 +08:00
parent d6bb9f6af4
commit 42a56b581d
35 changed files with 338 additions and 80 deletions
@@ -4,6 +4,8 @@ import jwt from 'jsonwebtoken';
import { CommonException } from '../../../basic/exception/common-exception.js';
import { RoleService } from '../../authority/service/role-service.js';
import { UserEntity } from '../../authority/entity/user.js';
import { SysSettingsService } from '../../system/service/sys-settings-service.js';
import { SysPrivateSettings } from '../../system/service/models.js';
/**
* 系统用户
@@ -17,6 +19,9 @@ export class LoginService {
@Config('auth.jwt')
private jwt: any;
@Inject()
sysSettingsService: SysSettingsService;
/**
* login
*/
@@ -47,7 +52,11 @@ export class LoginService {
roles: roleIds,
};
const expire = this.jwt.expire;
const token = jwt.sign(tokenInfo, this.jwt.secret, {
const setting = await this.sysSettingsService.getSetting<SysPrivateSettings>(SysPrivateSettings);
const jwtSecret = setting.jwtKey;
const token = jwt.sign(tokenInfo, jwtSecret, {
expiresIn: expire,
});