Skip to content

Commit

Permalink
fix: return StatusForbidden instead of StatusBadRequest
Browse files Browse the repository at this point in the history
...for cases where authorization failed
  • Loading branch information
pieterlukasse committed Jan 26, 2024
1 parent 75e4b48 commit 45b3110
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions controllers/cohortdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (u CohortDataController) RetrieveHistogramForCohortIdAndConceptId(c *gin.Co
validAccessRequest := u.teamProjectAuthz.TeamProjectValidation(c, []int{cohortId}, cohortPairs)
if !validAccessRequest {
log.Printf("Error: invalid request")
c.JSON(http.StatusBadRequest, gin.H{"message": "access denied"})
c.JSON(http.StatusForbidden, gin.H{"message": "access denied"})
c.Abort()
return
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func (u CohortDataController) RetrieveDataBySourceIdAndCohortIdAndVariables(c *g
validAccessRequest := u.teamProjectAuthz.TeamProjectValidation(c, []int{cohortId}, cohortPairs)
if !validAccessRequest {
log.Printf("Error: invalid request")
c.JSON(http.StatusBadRequest, gin.H{"message": "access denied"})
c.JSON(http.StatusForbidden, gin.H{"message": "access denied"})
c.Abort()
return
}
Expand Down Expand Up @@ -254,7 +254,7 @@ func (u CohortDataController) RetrieveCohortOverlapStatsWithoutFilteringOnConcep
validAccessRequest := u.teamProjectAuthz.TeamProjectValidation(c, []int{caseCohortId, controlCohortId}, cohortPairs)
if !validAccessRequest {
log.Printf("Error: invalid request")
c.JSON(http.StatusBadRequest, gin.H{"message": "access denied"})
c.JSON(http.StatusForbidden, gin.H{"message": "access denied"})
c.Abort()
return
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/concept.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (u ConceptController) RetrieveBreakdownStatsBySourceIdAndCohortId(c *gin.Co
validAccessRequest := u.teamProjectAuthz.TeamProjectValidationForCohort(c, cohortId)
if !validAccessRequest {
log.Printf("Error: invalid request")
c.JSON(http.StatusBadRequest, gin.H{"message": "access denied"})
c.JSON(http.StatusForbidden, gin.H{"message": "access denied"})
c.Abort()
return
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func (u ConceptController) RetrieveBreakdownStatsBySourceIdAndCohortIdAndVariabl
validAccessRequest := u.teamProjectAuthz.TeamProjectValidation(c, []int{cohortId}, cohortPairs)
if !validAccessRequest {
log.Printf("Error: invalid request")
c.JSON(http.StatusBadRequest, gin.H{"message": "access denied"})
c.JSON(http.StatusForbidden, gin.H{"message": "access denied"})
c.Abort()
return
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (u ConceptController) RetrieveAttritionTable(c *gin.Context) {
validAccessRequest := u.teamProjectAuthz.TeamProjectValidation(c, []int{cohortId}, cohortPairs)
if !validAccessRequest {
log.Printf("Error: invalid request")
c.JSON(http.StatusBadRequest, gin.H{"message": "access denied"})
c.JSON(http.StatusForbidden, gin.H{"message": "access denied"})
c.Abort()
return
}
Expand Down

0 comments on commit 45b3110

Please sign in to comment.