From 818ff6847e974c1501c2aad151f0050cc4f103be Mon Sep 17 00:00:00 2001 From: NitiwatOwen Date: Tue, 14 Nov 2023 15:56:56 +0700 Subject: [PATCH] handle duplicate token when logout --- src/auth/auth.service.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index ac25829..f3f3801 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -424,15 +424,20 @@ export class AuthService implements AuthServiceController { await this.userRepo.update(userId, { refreshToken: null, }); - } catch (e) { - if (e instanceof Prisma.PrismaClientKnownRequestError) { + } catch (error) { + console.log(error); + if (error instanceof Prisma.PrismaClientKnownRequestError) { console.log( 'There is a unique constraint violation, a blacklist should not outdated twice!', ); + throw new RpcException({ + code: status.ALREADY_EXISTS, + message: error.message, + }); } throw new RpcException({ code: status.INTERNAL, - message: e.message, + message: error.message, }); }