Linter fixes and proper error handling in PromoteToPm

This commit is contained in:
Imbus 2024-04-04 23:02:10 +02:00
parent 7635791f09
commit 1f4abc2a6a
3 changed files with 6 additions and 2 deletions

View file

@ -44,6 +44,10 @@ func PromoteToPm(c *fiber.Ctx) error {
// Add the user to the project with the specified role
err = db.GetDb(c).ChangeUserRole(new_pm_name, project, "project_manager")
if err != nil {
log.Info("Error promoting user to project manager:", err)
return c.Status(500).SendString(err.Error())
}
// Return success message
log.Info("User : ", new_pm_name, " promoted to project manager in project: ", project)

View file

@ -38,7 +38,7 @@ func GetAllWeeklyReports(c *fiber.Ctx) error {
return c.Status(500).SendString(err.Error())
}
if pm == false && target_user != username {
if pm && target_user != username {
log.Info("Unauthorized access")
return c.Status(403).SendString("Unauthorized access")
}

View file

@ -47,7 +47,7 @@ func GetWeeklyReport(c *fiber.Ctx) error {
return c.Status(500).SendString(err.Error())
}
if pm == false && target_user != username {
if pm && target_user != username {
log.Info("Unauthorized access")
return c.Status(403).SendString("Unauthorized access")
}