import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { User } from './user.entity'; @Injectable() export class AuthService { constructor( @InjectRepository(User) private usersRepository: Repository, ) { } async validateUser(login: string, password: string): Promise { // Ищем пользователя по login const user = await this.usersRepository.findOne({ where: { login } }); // Проверяем, что нашли пользователя и пароль совпадает if (user && user.password === password) { const { password, ...result } = user; return result; } return null; } }