Revert "fix: hardcode credentials"

This commit is contained in:
DenPiligrim
2026-02-06 12:54:29 +03:00
committed by GitHub
parent 9bbbc8cd97
commit 5d8ca39f6c
3 changed files with 5 additions and 20 deletions
+3 -7
View File
@@ -4,7 +4,6 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import * as bcrypt from 'bcrypt';
import { Setting } from '../settings/entities/setting.entity';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class AuthService {
@@ -14,7 +13,6 @@ export class AuthService {
@InjectRepository(Setting)
private settingsRepo: Repository<Setting>,
private jwtService: JwtService,
private configService: ConfigService,
) {}
async validateUser(login: string, pass: string): Promise<any> {
@@ -87,14 +85,12 @@ export class AuthService {
const login = await this.settingsRepo.findOne({ where: { key: 'admin_login' } });
if (!login) {
this.logger.log('Инициализация администратора...');
const envLogin = this.configService.get<string>('ADMIN_LOGIN') || 'admin';
const envPass = this.configService.get<string>('ADMIN_PASSWORD') || 'admin';
this.logger.log('Инициализация администратора (admin / admin)...');
const loginSetting = this.settingsRepo.create({ key: 'admin_login', value: envLogin });
const loginSetting = this.settingsRepo.create({ key: 'admin_login', value: 'admin' });
await this.settingsRepo.save(loginSetting);
const hash = await bcrypt.hash(envPass, 10);
const hash = await bcrypt.hash('admin', 10);
const passSetting = this.settingsRepo.create({ key: 'admin_password', value: hash });
await this.settingsRepo.save(passSetting);