refactor: change verify input as frontend cannot detect type
This commit is contained in:
parent
d2d4036bcd
commit
2da138939c
1 changed files with 32 additions and 28 deletions
|
|
@ -7,13 +7,15 @@ import HttpError from "../interfaces/http-error";
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
|
||||
type SendEmail = {
|
||||
identityNumber: string;
|
||||
email: string;
|
||||
} & ({ legalPersonNo: string } | { citizenId: string });
|
||||
};
|
||||
|
||||
type VerificationPayload = {
|
||||
identityNumber: string;
|
||||
email: string;
|
||||
otp: string;
|
||||
} & ({ legalPersonNo: string } | { citizenId: string });
|
||||
};
|
||||
|
||||
let emailTransport: ReturnType<(typeof nodemailer)["createTransport"]>;
|
||||
|
||||
|
|
@ -61,19 +63,20 @@ export class verificationController extends Controller {
|
|||
const dataCustomerBranch = await prisma.customerBranch.findFirst({
|
||||
where: {
|
||||
email: body.email,
|
||||
...("citizenId" in body
|
||||
? {
|
||||
citizenId: body.citizenId,
|
||||
customer: {
|
||||
customerType: "PERS",
|
||||
},
|
||||
}
|
||||
: {
|
||||
legalPersonNo: body.legalPersonNo,
|
||||
customer: {
|
||||
customerType: "CORP",
|
||||
},
|
||||
}),
|
||||
OR: [
|
||||
{
|
||||
citizenId: body.identityNumber,
|
||||
customer: {
|
||||
customerType: "PERS",
|
||||
},
|
||||
},
|
||||
{
|
||||
legalPersonNo: body.identityNumber,
|
||||
customer: {
|
||||
customerType: "CORP",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -105,19 +108,20 @@ export class verificationController extends Controller {
|
|||
const customerBranch = await prisma.customerBranch.findFirst({
|
||||
where: {
|
||||
email: body.email,
|
||||
...("citizenId" in body
|
||||
? {
|
||||
citizenId: body.citizenId,
|
||||
customer: {
|
||||
customerType: "PERS",
|
||||
},
|
||||
}
|
||||
: {
|
||||
legalPersonNo: body.legalPersonNo,
|
||||
customer: {
|
||||
customerType: "CORP",
|
||||
},
|
||||
}),
|
||||
OR: [
|
||||
{
|
||||
citizenId: body.identityNumber,
|
||||
customer: {
|
||||
customerType: "PERS",
|
||||
},
|
||||
},
|
||||
{
|
||||
legalPersonNo: body.identityNumber,
|
||||
customer: {
|
||||
customerType: "CORP",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue