Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

590 B
Raw Blame
import type { NextFunction, Request, Response } from 'express';
import { GoalPermissions } from '../../../types/auth.types';
import { resolveGoalId } from './resolveGoalId';

export const CanViewGraph = async (req: Request, res: Response, next: NextFunction) => {
    const goalId = await resolveGoalId(req);
    if (!goalId) {
        return res.status(400).end();
    }

    const checker = await req.appUser.permissionsFetcher.getCheckerForGoal(goalId);
    if (checker.hasPermissions(GoalPermissions.GRAPH_CAN_VIEW)) {
        return next();
    }

    return res.status(403).end();
};