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