Skip to content

Commit

Permalink
Fix private gist visibility (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Oct 4, 2023
1 parent 632206e commit 6f587f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/web/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (

func gistInit(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
currUser := getUserLogged(ctx)

userName := ctx.Param("user")
gistName := ctx.Param("gistname")

Expand All @@ -27,6 +29,13 @@ func gistInit(next echo.HandlerFunc) echo.HandlerFunc {
if err != nil {
return notFound("Gist not found")
}

if gist.Private == 2 {
if currUser == nil || currUser.ID != gist.UserID {
return notFound("Gist not found")
}
}

setData(ctx, "gist", gist)

if config.C.SshGit {
Expand Down Expand Up @@ -72,7 +81,7 @@ func gistInit(next echo.HandlerFunc) echo.HandlerFunc {
}
setData(ctx, "nbCommits", nbCommits)

if currUser := getUserLogged(ctx); currUser != nil {
if currUser != nil {
hasLiked, err := currUser.HasLiked(gist)
if err != nil {
return errorRes(500, "Cannot get user like status", err)
Expand Down

0 comments on commit 6f587f4

Please sign in to comment.