mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-08 21:50:13 +02:00
added user info in sign in and sign up return
This commit is contained in:
parent
b194d084cf
commit
73fd9bf8a1
@ -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,
|
||||
|
@ -14,7 +14,11 @@ export class UserService {
|
||||
id: userId,
|
||||
},
|
||||
include: {
|
||||
UserHasCrypto: true,
|
||||
UserHasCrypto: {
|
||||
include: {
|
||||
Crypto: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return user;
|
||||
|
0
src/utils/types.ts
Normal file
0
src/utils/types.ts
Normal file
Loading…
x
Reference in New Issue
Block a user