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.

641 B
Raw Blame
import type { NextFunction, Request, Response } from 'express'
import { ORG_ADMIN_ROLES, type OrgRole } from '../../organizations/types'

export const canAddGoal = async (req: Request, res: Response, next: NextFunction) => {
    if (req.appUser.isBlocked()) {
        return res.status(403).end()
    }

    const organizationId = req.body.organizationId
    if (organizationId) {
        const member = await req.appUser.organizationManager.getCurrentUserMember(Number(organizationId))
        if (!member || !ORG_ADMIN_ROLES.includes(member.role as OrgRole)) {
            return res.status(403).end()
        }
    }

    return next()
}