Skip to content

Commit

Permalink
return non 404 error when the session does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sandromello committed Dec 27, 2024
1 parent 5eb97c5 commit 48bb33c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions gateway/api/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,18 @@ func Get(c *gin.Context) {

sessionID := c.Param("session_id")
session, err := models.GetSessionByID(ctx.OrgID, sessionID)
if err != nil {
switch err {
case models.ErrNotFound:
c.JSON(http.StatusNotFound, gin.H{"message": "not found"})
return
case nil:
default:
log.Errorf("failed fetching session, err=%v", err)
sentry.CaptureException(err)
c.JSON(http.StatusInternalServerError, gin.H{"message": "failed fetching session"})
return
}

// if not found, return 404
if session == nil {
c.JSON(http.StatusNotFound, gin.H{"message": "not found"})
return
}

// if user is not admin or auditor and session is not owned by user, return 404
if session.UserID != ctx.UserID && !ctx.IsAuditorOrAdminUser() {
c.JSON(http.StatusNotFound, gin.H{"message": "not found"})
Expand Down

0 comments on commit 48bb33c

Please sign in to comment.