diff --git a/api/auth.go b/api/auth.go index d1b27a5..5a84a9d 100644 --- a/api/auth.go +++ b/api/auth.go @@ -158,7 +158,13 @@ func (api *WebAPI) GetManagerList(r *Request) { func (api *WebAPI) GetManagerListWithRoleOn(r *Request) { pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64) - handleErr(err, r) //todo handle invalid id + if err != nil || pid <= 0 { + r.Json(JsonResponse{ + Ok: false, + Message: "Invalid project id", + }, 400) + return + } sess := api.Session.StartFasthttp(r.Ctx) manager := sess.Get("manager") diff --git a/api/helper.go b/api/helper.go index 0702510..e59961f 100644 --- a/api/helper.go +++ b/api/helper.go @@ -27,13 +27,14 @@ func (r *Request) Json(object JsonResponse, code int) { logrus.WithError(err).WithFields(logrus.Fields{ "code": code, }).Error("Error during json encoding of object") + return } r.Ctx.Response.SetStatusCode(code) r.Ctx.Response.Header.Set("Content-Type", "application/json") _, err = r.Ctx.Write(resp) if err != nil { - panic(err) //todo handle differently + panic(err) } } diff --git a/api/project.go b/api/project.go index 3310a4d..0212669 100644 --- a/api/project.go +++ b/api/project.go @@ -525,7 +525,6 @@ func (api *WebAPI) SetManagerRoleOnProject(r *Request) { func (api *WebAPI) SetSecret(r *Request) { pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64) - handleErr(err, r) //todo handle invalid id if err != nil || pid <= 0 { r.Json(JsonResponse{ Ok: false, diff --git a/api/task.go b/api/task.go index a350aec..c6993d6 100644 --- a/api/task.go +++ b/api/task.go @@ -66,7 +66,6 @@ func (api *WebAPI) SubmitTask(r *Request) { } if createReq.UniqueString != "" { - //TODO: Load key from config createReq.Hash64 = int64(siphash.Hash(1, 2, []byte(createReq.UniqueString))) } diff --git a/storage/task.go b/storage/task.go index 2bf2c7b..b895558 100644 --- a/storage/task.go +++ b/storage/task.go @@ -39,7 +39,6 @@ func (database *Database) SaveTask(task *Task, project int64, hash64 int64, wid db := database.getDB() - //TODO: For some reason it refuses to insert the 64-bit value unless I do that... res, err := db.Exec(fmt.Sprintf(` INSERT INTO task (project, max_retries, recipe, priority, max_assign_time, hash64,verification_count) SELECT $1,$2,$3,$4,$5,NULLIF(%d, 0),$6 FROM worker_access