fix: line user not registered for all customer branch
This commit is contained in:
parent
ccbf21f71d
commit
6f1969c829
2 changed files with 89 additions and 14 deletions
|
|
@ -25,7 +25,18 @@ export class verificationController extends Controller {
|
|||
@Get()
|
||||
@Security("line")
|
||||
async isRegistered(@Request() req: RequestWithLineUser) {
|
||||
return !!(await prisma.customerBranch.findFirst({ where: { userId: req.user.sub } }));
|
||||
return !!(await prisma.customerBranch.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{ userId: req.user.sub },
|
||||
{
|
||||
customer: {
|
||||
branch: { some: { userId: req.user.sub } },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
@Post("/send-otp")
|
||||
|
|
@ -133,13 +144,11 @@ export class verificationController extends Controller {
|
|||
customerBranch.otpExpires &&
|
||||
customerBranch.otpExpires >= new Date()
|
||||
) {
|
||||
const dataCustomer = await prisma.customerBranch.update({
|
||||
const dataCustomer = await prisma.customerBranch.updateMany({
|
||||
where: {
|
||||
id: customerBranch.id,
|
||||
},
|
||||
data: {
|
||||
userId: req.user.sub,
|
||||
customerId: customerBranch.customerId,
|
||||
},
|
||||
data: { userId: req.user.sub },
|
||||
});
|
||||
|
||||
return dataCustomer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue