feat: change exception structure

This commit is contained in:
Sergey Krylov 2026-01-25 10:51:02 +03:00
parent bbbfb889ff
commit c79381e79c
2 changed files with 12 additions and 3 deletions

View File

@ -61,7 +61,10 @@ export class AuthService {
: await this.authRepository.findByEmail(identifier)
if (!account) {
throw new RpcException('Account not found')
throw new RpcException({
code: 5,
details: 'Account not found'
})
}
if (isPhoneType && !account.isPhoneVerified) {

View File

@ -31,12 +31,18 @@ export class OtpService {
)
if (!stroredHash) {
throw new RpcException('Invalid or expired code')
throw new RpcException({
code: 5,
details: 'Invalid or expired code'
})
}
const hash = createHash('sha256').update(code).digest('hex')
if (stroredHash !== hash) {
throw new RpcException('Invalid or expired code')
throw new RpcException({
code: 5,
details: 'Invalid or expired code'
})
}
await this.redisService.del(`otp:${type}:${indentifier}`)