secure type with passphrase
This commit is contained in:
parent
597feef9ef
commit
8f49533fcb
9 changed files with 44 additions and 2 deletions
|
@ -101,11 +101,13 @@ export async function createCalendarType(req: Request, res: Response): Promise<a
|
|||
const type = req.body.type;
|
||||
const nscdr = req.body.nscdr;
|
||||
const color = req.body.color;
|
||||
const passphrase = req.body.passphrase;
|
||||
|
||||
let createType: CreateCalendarTypeCommand = {
|
||||
type,
|
||||
nscdr,
|
||||
color,
|
||||
passphrase,
|
||||
};
|
||||
let id = await CalendarTypeCommandHandler.create(createType);
|
||||
|
||||
|
@ -154,12 +156,14 @@ export async function updateCalendarType(req: Request, res: Response): Promise<a
|
|||
const type = req.body.type;
|
||||
const nscdr = req.body.nscdr;
|
||||
const color = req.body.color;
|
||||
const passphrase = req.body.passphrase;
|
||||
|
||||
let updateType: UpdateCalendarTypeCommand = {
|
||||
id,
|
||||
type,
|
||||
nscdr,
|
||||
color,
|
||||
passphrase,
|
||||
};
|
||||
await CalendarTypeCommandHandler.update(updateType);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import CalendarFactory from "../factory/admin/calendar";
|
|||
|
||||
/**
|
||||
* @description get all calendar items by types or nscdr
|
||||
* @summary passphrase is passed as value pair like `type:passphrase`
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
|
@ -22,8 +23,14 @@ export async function getCalendarItemsByTypes(req: Request, res: Response): Prom
|
|||
}
|
||||
|
||||
let items: Array<calendar> = [];
|
||||
if (types.length == 0) {
|
||||
let typeIds = await CalendarTypeService.getByTypes(types as Array<string>);
|
||||
if (types.length != 0) {
|
||||
let typeIds = await CalendarTypeService.getByTypes((types as Array<string>).map((t) => t.split(":")[0]));
|
||||
typeIds = typeIds.filter(
|
||||
(ti) =>
|
||||
ti.passphrase == null ||
|
||||
ti.passphrase == "" ||
|
||||
ti.passphrase == (types as Array<string>).find((t) => t.includes(ti.type)).split(":")[1]
|
||||
);
|
||||
items = await CalendarService.getByTypes(typeIds.map((t) => t.id));
|
||||
} else {
|
||||
items = await CalendarService.getByTypeNSCDR();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue