Steam
- 1 ответ
- 0 вопросов
2
Вклад в тег
async login(email: string, password: string) {
const user = await User.findOne({ where: { email } })
var isPassEquals = false;
if (user) {
isPassEquals = await bcrypt.compare(password, user.password)
}
if (!user || !isPassEquals) {
throw ApiError.BadRequest('Your email or password was entered incorrectly.')
}
const userDto = new UserDto(user)
const tokens = tokenService.generateTokens(userDto.id, userDto.email)
await tokenService.saveToken(userDto.id, tokens.refreshToken)
return { ...tokens, user: userDto }
}