package projects import ( db "ttime/internal/database" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/log" "github.com/golang-jwt/jwt/v5" ) // IsProjectManagerHandler is a handler that checks if a user is a project manager for a given project func IsProjectManagerHandler(c *fiber.Ctx) error { // Get the username from the token user := c.Locals("user").(*jwt.Token) claims := user.Claims.(jwt.MapClaims) username := claims["name"].(string) // Extract necessary parameters from the request query string projectName := c.Params("projectName") log.Info("Checking if user ", username, " is a project manager for project ", projectName) // Check if the user is a project manager for the specified project isManager, err := db.GetDb(c).IsProjectManager(username, projectName) if err != nil { log.Info("Error checking project manager status:", err) return c.Status(500).SendString(err.Error()) } // Return the result as JSON return c.JSON(fiber.Map{"isProjectManager": isManager}) }