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 { AccountInclude, AccountWhereUniqueInput } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service' import { PrismaService } from '@/prisma/prisma.service'
import { Injectable, NotFoundException } from '@nestjs/common' import { Injectable, NotFoundException } from '@nestjs/common'
@@ -26,31 +27,32 @@ export class AuthService {
let accountInclude: AccountInclude = {} let accountInclude: AccountInclude = {}
// console.error('isPos', isPos) console.error('isPos', isPos)
// if (isPos) { if (isPos) {
// if (!device_info?.id) { if (!device_info?.id) {
// throw new NotFoundException('اطلاعات ورودی شما اشتباه است') throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
// } }
// accountWhere = { accountWhere = {
// ...accountWhere, ...accountWhere,
// consumer_account: { consumer_account: {
// pos: { pos: {
// isNot: null, isNot: null,
// }, },
// }, },
// } }
// accountInclude = { accountInclude = {
// ...accountInclude, ...accountInclude,
// consumer_account: { consumer_account: {
// select: { select: {
// id: true, id: true,
// account_device: true, account_device: true,
// }, role: true,
// }, },
// } },
// } }
}
const account = await this.prisma.account.findUnique({ const account = await this.prisma.account.findUnique({
where: accountWhere, where: accountWhere,
@@ -62,10 +64,13 @@ export class AuthService {
} }
await this.authUtils.checkAuthPassword(password, account.password) await this.authUtils.checkAuthPassword(password, account.password)
// if (isPos) { if (isPos) {
// if (!account.consumer_account) { if (
// throw new NotFoundException('اطلاعات ورودی شما اشتباه است') !account.consumer_account ||
// } account.consumer_account.role !== ConsumerRole.OPERATOR
) {
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
}
// const { account_device, id } = account.consumer_account as any // const { account_device, id } = account.consumer_account as any
// if (account_device?.device_id !== device_info!.id) { // if (account_device?.device_id !== device_info!.id) {
@@ -97,7 +102,7 @@ export class AuthService {
// }, // },
// }, // },
// }) // })
// } }
const preparedData = await this.authUtils.generateLoginResponse(account) const preparedData = await this.authUtils.generateLoginResponse(account)
return ResponseMapper.create(preparedData) return ResponseMapper.create(preparedData)