Add some sanity checking in SubmitWeeklyReport route
This commit is contained in:
parent
23dd22eab5
commit
0d053add5e
1 changed files with 8 additions and 0 deletions
|
@ -267,6 +267,14 @@ func (gs *GState) SubmitWeeklyReport(c *fiber.Ctx) error {
|
|||
return c.Status(400).SendString(err.Error())
|
||||
}
|
||||
|
||||
// Make sure all the fields of the report are valid
|
||||
if report.Week < 1 || report.Week > 52 {
|
||||
return c.Status(400).SendString("Invalid week number")
|
||||
}
|
||||
if report.DevelopmentTime < 0 || report.MeetingTime < 0 || report.AdminTime < 0 || report.OwnWorkTime < 0 || report.StudyTime < 0 || report.TestingTime < 0 {
|
||||
return c.Status(400).SendString("Invalid time report")
|
||||
}
|
||||
|
||||
if err := gs.Db.AddWeeklyReport(report.ProjectName, username, report.Week, report.DevelopmentTime, report.MeetingTime, report.AdminTime, report.OwnWorkTime, report.StudyTime, report.TestingTime); err != nil {
|
||||
return c.Status(500).SendString(err.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue