From e40bedc91ccf6db34691dc58512f974d7c7e12b7 Mon Sep 17 00:00:00 2001 From: Andrea Fazzi Date: Mon, 3 Feb 2020 17:12:15 +0100 Subject: [PATCH] Fix regression: ambiguity between user_id and model_id --- handlers/compose/docker-compose.yml | 2 +- orm/participant.go | 6 +++--- orm/school.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers/compose/docker-compose.yml b/handlers/compose/docker-compose.yml index 20925919..8fb42028 100644 --- a/handlers/compose/docker-compose.yml +++ b/handlers/compose/docker-compose.yml @@ -16,7 +16,7 @@ services: smtp: image: digiplant/fake-smtp - container_name: oef_test_smtp + container_name: oef_test_handlers_smtp ports: - "1025:25" diff --git a/orm/participant.go b/orm/participant.go index 85b07575..45f3f1bd 100644 --- a/orm/participant.go +++ b/orm/participant.go @@ -210,7 +210,7 @@ func (model *Participant) Create(db *Database, args map[string]string, w http.Re // If user has "school" role get school id from token if isSchool(r) { - schoolID, err := strconv.Atoi(getUserIDFromToken(r)) + schoolID, err := strconv.Atoi(getModelIDFromToken(r)) if err != nil { return nil, err } @@ -267,7 +267,7 @@ func (model *Participant) Read(db *Database, args map[string]string, w http.Resp return nil, err } - if strconv.Itoa(int(participant.SchoolID)) != getUserIDFromToken(r) { + if strconv.Itoa(int(participant.SchoolID)) != getModelIDFromToken(r) { return nil, errors.NotAuthorized } @@ -304,7 +304,7 @@ func (model *Participant) ReadAll(db *Database, args map[string]string, w http.R // School user can access to its participants only! if isSchool(r) { - schoolId, err := strconv.Atoi(getUserIDFromToken(r)) + schoolId, err := strconv.Atoi(getModelIDFromToken(r)) if err != nil { return nil, err } diff --git a/orm/school.go b/orm/school.go index b40d0ebc..4434b769 100644 --- a/orm/school.go +++ b/orm/school.go @@ -207,7 +207,7 @@ func (model *School) Read(db *Database, args map[string]string, w http.ResponseW id := args["id"] - if isSchool(r) && id != getUserIDFromToken(r) { + if isSchool(r) && id != getModelIDFromToken(r) { return nil, errors.NotAuthorized }