update pos consumer module
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
createParamDecorator,
|
||||
ExecutionContext,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common'
|
||||
import { Request } from 'express'
|
||||
import { IPosPayload } from '../models/posPayload.model'
|
||||
|
||||
export const PosInfo = createParamDecorator(
|
||||
(data: keyof IPosPayload | undefined, ctx: ExecutionContext) => {
|
||||
try {
|
||||
const request = ctx.switchToHttp().getRequest<Request>()
|
||||
const posInfo = request.posData
|
||||
|
||||
if (!posInfo) {
|
||||
throw new UnauthorizedException('شما به این بخش دسترسی ندارید')
|
||||
}
|
||||
|
||||
if (data) {
|
||||
return posInfo[data]
|
||||
}
|
||||
|
||||
return posInfo
|
||||
} catch (err) {
|
||||
throw new BadRequestException('مشکلی در ساختار درخواست شما وجود دارد.')
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AccessTokenPayload } from '@/modules/auth/models'
|
||||
import { AccessTokenPayload } from '@/common/models/tokenPayload.model'
|
||||
import {
|
||||
BadRequestException,
|
||||
createParamDecorator,
|
||||
@@ -29,6 +29,8 @@ export const TokenAccount = createParamDecorator(
|
||||
// ✅ if called with no param — return full account object
|
||||
return account
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
||||
throw new BadRequestException('مشکلی در ساختار درخواست شما وجود دارد.')
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user