Skip to content

Commit

Permalink
remove id and owner checking from controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mariscalromeroalejandro committed Jan 29, 2025
1 parent 5050de2 commit eddaa5b
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions QualityControl/lib/controllers/LayoutController.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,8 @@ export class LayoutController {
async deleteLayoutHandler(req, res) {
const { id } = req.params;
try {
if (!id) {
updateAndSendExpressResponseFromNativeError(
res,
new InvalidInputError('Missing parameter "id" of layout to delete'),
);
} else {
const { personid, name } = req.session;
const { owner_name, owner_id } = await this._dataService.readLayout(id);
if (owner_name !== name || owner_id !== personid) {
updateAndSendExpressResponseFromNativeError(
res,
new UnauthorizedAccessError('Only the owner of the layout can delete it'),
);
} else {
const result = await this._dataService.deleteLayout(id);
res.status(200).json(result);
}
}
const result = await this._dataService.deleteLayout(id);
res.status(200).json(result);
} catch {
updateAndSendExpressResponseFromNativeError(res, new Error(`Unable to delete layout with id: ${id}`));
}
Expand Down

0 comments on commit eddaa5b

Please sign in to comment.