mirror of
https://github.com/certd/certd.git
synced 2026-05-18 14:27:36 +08:00
chore: project
This commit is contained in:
@@ -23,7 +23,7 @@ export class TwoFactorService {
|
||||
const { authenticator } = await import("otplib");
|
||||
|
||||
authenticatorSetting.secret = authenticator.generateSecret()
|
||||
await this.userSettingsService.saveSetting(userId, setting);
|
||||
await this.userSettingsService.saveSetting(userId, null, setting);
|
||||
}
|
||||
|
||||
const user = await this.userService.info(userId);
|
||||
@@ -59,7 +59,7 @@ export class TwoFactorService {
|
||||
authenticatorSetting.enabled = true;
|
||||
authenticatorSetting.verified = true;
|
||||
|
||||
await this.userSettingsService.saveSetting(userId, setting);
|
||||
await this.userSettingsService.saveSetting(userId, null, setting);
|
||||
}
|
||||
|
||||
async offAuthenticator(userId:number) {
|
||||
@@ -71,11 +71,11 @@ export class TwoFactorService {
|
||||
setting.authenticator.enabled = false;
|
||||
setting.authenticator.verified = false;
|
||||
setting.authenticator.secret = '';
|
||||
await this.userSettingsService.saveSetting(userId, setting);
|
||||
await this.userSettingsService.saveSetting(userId, null, setting);
|
||||
}
|
||||
|
||||
async getSetting(userId:number) {
|
||||
return await this.userSettingsService.getSetting<UserTwoFactorSetting>(userId, UserTwoFactorSetting);
|
||||
return await this.userSettingsService.getSetting<UserTwoFactorSetting>(userId, null, UserTwoFactorSetting);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ export class UserSettingsService extends BaseService<UserSettingsEntity> {
|
||||
}
|
||||
|
||||
async getByKey(key: string, userId: number, projectId: number): Promise<UserSettingsEntity | null> {
|
||||
if(!userId){
|
||||
if(userId == null){
|
||||
throw new Error('userId is required');
|
||||
}
|
||||
if (!key || !userId) {
|
||||
if (!key) {
|
||||
return null;
|
||||
}
|
||||
return await this.repository.findOne({
|
||||
@@ -54,7 +54,7 @@ export class UserSettingsService extends BaseService<UserSettingsEntity> {
|
||||
}
|
||||
|
||||
async getSettingByKey(key: string, userId: number, projectId: number): Promise<any | null> {
|
||||
if(!userId){
|
||||
if(userId == null){
|
||||
throw new Error('userId is required');
|
||||
}
|
||||
const entity = await this.getByKey(key, userId, projectId);
|
||||
@@ -83,7 +83,7 @@ export class UserSettingsService extends BaseService<UserSettingsEntity> {
|
||||
|
||||
|
||||
async getSetting<T>( userId: number, projectId: number,type: any, cache:boolean = false): Promise<T> {
|
||||
if(!userId){
|
||||
if(userId==null){
|
||||
throw new Error('userId is required');
|
||||
}
|
||||
const key = type.__key__;
|
||||
@@ -110,7 +110,7 @@ export class UserSettingsService extends BaseService<UserSettingsEntity> {
|
||||
}
|
||||
|
||||
async saveSetting<T extends BaseSettings>(userId:number, projectId: number,bean: T) {
|
||||
if(!userId){
|
||||
if(userId == null){
|
||||
throw new Error('userId is required');
|
||||
}
|
||||
const old = await this.getSetting(userId, projectId,bean.constructor)
|
||||
|
||||
Reference in New Issue
Block a user