This commit is contained in:
2026-05-11 20:15:31 +03:30
parent 2a4e778c31
commit 1b26c515c0
+33 -28
View File
@@ -1,3 +1,4 @@
import { ConsumerRole } from '@/generated/prisma/enums'
import { AccountInclude, AccountWhereUniqueInput } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable, NotFoundException } from '@nestjs/common'
@@ -26,31 +27,32 @@ export class AuthService {
let accountInclude: AccountInclude = {}
// console.error('isPos', isPos)
console.error('isPos', isPos)
// if (isPos) {
// if (!device_info?.id) {
// throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
// }
// accountWhere = {
// ...accountWhere,
// consumer_account: {
// pos: {
// isNot: null,
// },
// },
// }
if (isPos) {
if (!device_info?.id) {
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
}
accountWhere = {
...accountWhere,
consumer_account: {
pos: {
isNot: null,
},
},
}
// accountInclude = {
// ...accountInclude,
// consumer_account: {
// select: {
// id: true,
// account_device: true,
// },
// },
// }
// }
accountInclude = {
...accountInclude,
consumer_account: {
select: {
id: true,
account_device: true,
role: true,
},
},
}
}
const account = await this.prisma.account.findUnique({
where: accountWhere,
@@ -62,10 +64,13 @@ export class AuthService {
}
await this.authUtils.checkAuthPassword(password, account.password)
// if (isPos) {
// if (!account.consumer_account) {
// throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
// }
if (isPos) {
if (
!account.consumer_account ||
account.consumer_account.role !== ConsumerRole.OPERATOR
) {
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
}
// const { account_device, id } = account.consumer_account as any
// if (account_device?.device_id !== device_info!.id) {
@@ -97,7 +102,7 @@ export class AuthService {
// },
// },
// })
// }
}
const preparedData = await this.authUtils.generateLoginResponse(account)
return ResponseMapper.create(preparedData)