mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 03:10:38 +09:00
Fix budget auth and monthly spend rollups
This commit is contained in:
parent
5f2c2ee0e2
commit
728d9729ed
7 changed files with 315 additions and 17 deletions
|
|
@ -250,6 +250,7 @@ export function costRoutes(db: Db) {
|
|||
router.patch("/companies/:companyId/budgets", validate(updateBudgetSchema), async (req, res) => {
|
||||
assertBoard(req);
|
||||
const companyId = req.params.companyId as string;
|
||||
assertCompanyAccess(req, companyId);
|
||||
const company = await companies.update(companyId, { budgetMonthlyCents: req.body.budgetMonthlyCents });
|
||||
if (!company) {
|
||||
res.status(404).json({ error: "Company not found" });
|
||||
|
|
@ -288,6 +289,8 @@ export function costRoutes(db: Db) {
|
|||
return;
|
||||
}
|
||||
|
||||
assertCompanyAccess(req, agent.companyId);
|
||||
|
||||
if (req.actor.type === "agent") {
|
||||
if (req.actor.agentId !== agentId) {
|
||||
res.status(403).json({ error: "Agent can only change its own budget" });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue