From 73fd9bf8a13831736e01857fceee1ee6e67bc33b Mon Sep 17 00:00:00 2001 From: Kevsl Date: Fri, 7 Jun 2024 14:37:41 +0200 Subject: [PATCH] added user info in sign in and sign up return --- src/auth/auth.service.ts | 16 +++++++++++----- src/user/user.service.ts | 6 +++++- src/utils/types.ts | 0 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/utils/types.ts diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index f10061a..a5675a2 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -59,20 +59,26 @@ export class AuthService { } async signin(dto: AuthLoginDto) { - const user = await this.prisma.user.findUnique({ + const userDatas = await this.prisma.user.findUnique({ where: { email: dto.email, }, + include: { + UserHasCrypto: { + include: { Crypto: true }, + }, + Role: true, + }, }); - if (!user) throw new ForbiddenException('Credentials incorrect'); + if (!userDatas) throw new ForbiddenException('Credentials incorrect'); - const pwMatches = await argon.verify(user.hash, dto.password); + const pwMatches = await argon.verify(userDatas.hash, dto.password); if (!pwMatches) throw new ForbiddenException('Credentials incorrect'); - return this.signToken(user); + return this.signToken(userDatas); } - async signToken(user: User): Promise<{ access_token: string; user: User }> { + async signToken(user: any): Promise<{ access_token: string; user: User }> { const payload = { sub: user.id, email: user.email, diff --git a/src/user/user.service.ts b/src/user/user.service.ts index 519d7ba..a5dbf55 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -14,7 +14,11 @@ export class UserService { id: userId, }, include: { - UserHasCrypto: true, + UserHasCrypto: { + include: { + Crypto: true, + }, + }, }, }); return user; diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 0000000..e69de29