Edição correta nos arquivos .ts da controler UserCOntroller.ts e WhatsaAppController.ts, esses arquivos são modificados e é refletido no diretório dist que contem os mesmo arquivos em javascript .js

pull/1/head
adriano 2022-01-13 14:11:50 -03:00
parent 0a24a01e6f
commit 2eed62f753
3 changed files with 25 additions and 5 deletions

View File

@ -23,8 +23,18 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
pageNumber
});
if(req.user.profile!=='master'){
let auxUsers: Array<object> = [];
for (var user of users) {
if(user.profile!=='master'){
auxUsers.push(user)
}
}
return res.json({ users: auxUsers, count, hasMore });
}
return res.json({ users, count, hasMore });
};
@ -67,7 +77,7 @@ export const update = async (
req: Request,
res: Response
): Promise<Response> => {
if (req.user.profile !== "admin") {
if (req.user.profile !== "admin" && req.user.profile !== "master") {
throw new AppError("ERR_NO_PERMISSION", 403);
}

View File

@ -9,6 +9,8 @@ import ListWhatsAppsService from "../services/WhatsappService/ListWhatsAppsServi
import ShowWhatsAppService from "../services/WhatsappService/ShowWhatsAppService";
import UpdateWhatsAppService from "../services/WhatsappService/UpdateWhatsAppService";
import AppError from "../errors/AppError";
interface WhatsappData {
name: string;
queueIds: number[];
@ -34,6 +36,10 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
queueIds
}: WhatsappData = req.body;
if (req.user.profile !== "master") {
throw new AppError("ERR_NO_PERMISSION", 403);
}
const { whatsapp, oldDefaultWhatsapp } = await CreateWhatsAppService({
name,
status,
@ -101,6 +107,11 @@ export const remove = async (
req: Request,
res: Response
): Promise<Response> => {
if (req.user.profile !== "master") {
throw new AppError("ERR_NO_PERMISSION", 403);
}
const { whatsappId } = req.params;
await DeleteWhatsAppService(whatsappId);

View File

@ -17,7 +17,6 @@ const rules = {
"queues-view:show",
"user-view:show",
],
},