mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 06:00:12 +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) {
|
async signin(dto: AuthLoginDto) {
|
||||||
const user = await this.prisma.user.findUnique({
|
const userDatas = await this.prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
email: dto.email,
|
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');
|
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 = {
|
const payload = {
|
||||||
sub: user.id,
|
sub: user.id,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
|
@ -14,7 +14,11 @@ export class UserService {
|
|||||||
id: userId,
|
id: userId,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
UserHasCrypto: true,
|
UserHasCrypto: {
|
||||||
|
include: {
|
||||||
|
Crypto: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return user;
|
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