Skip to content
Snippets Groups Projects
Verified Commit 8f7c2247 authored by Adrian Paschkowski's avatar Adrian Paschkowski :thinking:
Browse files

Fix issues with null token codes, return code with getAgent

parent 9086ebee
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ export class AgentResolver { ...@@ -33,6 +33,7 @@ export class AgentResolver {
) { ) {
const agent = await this.prismaService.agent.findFirst({ const agent = await this.prismaService.agent.findFirst({
where: { slug: code }, where: { slug: code },
include: { tokenCode: true },
}); });
if (!agent) throw new NotFoundException(); if (!agent) throw new NotFoundException();
......
import { UseGuards, NotFoundException, UnauthorizedException, ForbiddenException } from '@nestjs/common'; import {
UseGuards,
NotFoundException,
UnauthorizedException,
ForbiddenException,
} from '@nestjs/common';
import { import {
Args, Args,
Context, Context,
...@@ -42,11 +47,13 @@ export class TokenCodeResolver { ...@@ -42,11 +47,13 @@ export class TokenCodeResolver {
if (!agent) throw new ForbiddenException(); if (!agent) throw new ForbiddenException();
let tokenCode = await this.prismaService.tokenCode.findFirst({ let tokenCode =
where: { agent.tokenCodeId &&
id: agent.tokenCodeId, (await this.prismaService.tokenCode.findFirst({
}, where: {
}); id: agent.tokenCodeId,
},
}));
if (!tokenCode) { if (!tokenCode) {
tokenCode = await this.prismaService.tokenCode.create({ tokenCode = await this.prismaService.tokenCode.create({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment