Statistics

This commit is contained in:
Imbus 2024-04-15 11:44:19 +02:00
parent b51a00b723
commit a3f16e713a

View file

@ -32,17 +32,12 @@ func GetStatistics(c *fiber.Ctx) error {
return c.Status(500).SendString(err.Error()) return c.Status(500).SendString(err.Error())
} }
if userNameParam == "" { // Bail if the user is not a PM or checking its own statistics
userNameParam = username if !pm && userNameParam != "" && userNameParam != username {
} log.Info("Unauthorized access for user: ", username, "trying to access project: ", projectName, "statistics for user: ", userNameParam)
if !pm || userNameParam != username {
log.Info("Unauthorized access for user:", username, "trying to access project:", projectName, "statistics for user:", userNameParam)
return c.Status(403).SendString("Unauthorized access") return c.Status(403).SendString("Unauthorized access")
} }
username = userNameParam
// Retrieve statistics for the project from the database // Retrieve statistics for the project from the database
statistics, err := db.GetDb(c).ReportStatistics(username, projectName) statistics, err := db.GetDb(c).ReportStatistics(username, projectName)
if err != nil { if err != nil {