mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
refactor(server): config service (#13066)
* refactor(server): config service * fix: function renaming --------- Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { SALT_ROUNDS } from 'src/constants';
|
||||
import { SystemConfigCore } from 'src/cores/system-config.core';
|
||||
import { UserAdminResponseDto, mapUserAdmin } from 'src/dtos/user.dto';
|
||||
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
|
||||
import { IUserRepository } from 'src/interfaces/user.interface';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
|
||||
@Injectable()
|
||||
export class CliService {
|
||||
private configCore: SystemConfigCore;
|
||||
|
||||
export class CliService extends BaseService {
|
||||
constructor(
|
||||
@Inject(ICryptoRepository) private cryptoRepository: ICryptoRepository,
|
||||
@Inject(ISystemMetadataRepository) systemMetadataRepository: ISystemMetadataRepository,
|
||||
@Inject(IUserRepository) private userRepository: IUserRepository,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
@Inject(ILoggerRepository) logger: ILoggerRepository,
|
||||
) {
|
||||
super(systemMetadataRepository, logger);
|
||||
this.logger.setContext(CliService.name);
|
||||
this.configCore = SystemConfigCore.create(systemMetadataRepository, this.logger);
|
||||
}
|
||||
|
||||
async listUsers(): Promise<UserAdminResponseDto[]> {
|
||||
@@ -42,26 +40,26 @@ export class CliService {
|
||||
}
|
||||
|
||||
async disablePasswordLogin(): Promise<void> {
|
||||
const config = await this.configCore.getConfig({ withCache: false });
|
||||
const config = await this.getConfig({ withCache: false });
|
||||
config.passwordLogin.enabled = false;
|
||||
await this.configCore.updateConfig(config);
|
||||
await this.updateConfig(config);
|
||||
}
|
||||
|
||||
async enablePasswordLogin(): Promise<void> {
|
||||
const config = await this.configCore.getConfig({ withCache: false });
|
||||
const config = await this.getConfig({ withCache: false });
|
||||
config.passwordLogin.enabled = true;
|
||||
await this.configCore.updateConfig(config);
|
||||
await this.updateConfig(config);
|
||||
}
|
||||
|
||||
async disableOAuthLogin(): Promise<void> {
|
||||
const config = await this.configCore.getConfig({ withCache: false });
|
||||
const config = await this.getConfig({ withCache: false });
|
||||
config.oauth.enabled = false;
|
||||
await this.configCore.updateConfig(config);
|
||||
await this.updateConfig(config);
|
||||
}
|
||||
|
||||
async enableOAuthLogin(): Promise<void> {
|
||||
const config = await this.configCore.getConfig({ withCache: false });
|
||||
const config = await this.getConfig({ withCache: false });
|
||||
config.oauth.enabled = true;
|
||||
await this.configCore.updateConfig(config);
|
||||
await this.updateConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user