feat: change exception structure
This commit is contained in:
parent
bbbfb889ff
commit
c79381e79c
@ -61,7 +61,10 @@ export class AuthService {
|
|||||||
: await this.authRepository.findByEmail(identifier)
|
: await this.authRepository.findByEmail(identifier)
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new RpcException('Account not found')
|
throw new RpcException({
|
||||||
|
code: 5,
|
||||||
|
details: 'Account not found'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPhoneType && !account.isPhoneVerified) {
|
if (isPhoneType && !account.isPhoneVerified) {
|
||||||
|
|||||||
@ -31,12 +31,18 @@ export class OtpService {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!stroredHash) {
|
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')
|
const hash = createHash('sha256').update(code).digest('hex')
|
||||||
if (stroredHash !== hash) {
|
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}`)
|
await this.redisService.del(`otp:${type}:${indentifier}`)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user