From 12625ed462b99557dae87f0e4471817c282db7bf Mon Sep 17 00:00:00 2001 From: Thomas Miceli Date: Wed, 15 Mar 2023 01:01:42 +0100 Subject: [PATCH] Disable self-fork --- internal/web/gist.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/web/gist.go b/internal/web/gist.go index c48dcb7..bf58406 100644 --- a/internal/web/gist.go +++ b/internal/web/gist.go @@ -424,6 +424,11 @@ func fork(ctx echo.Context) error { return errorRes(500, "Error checking if gist is already forked", err) } + if gist.User.ID == currentUser.ID { + addFlash(ctx, "Unable to fork own gists", "error") + return redirect(ctx, "/"+gist.User.Username+"/"+gist.Uuid) + } + if alreadyForked.ID != 0 { return redirect(ctx, "/"+alreadyForked.User.Username+"/"+alreadyForked.Uuid) } @@ -455,6 +460,8 @@ func fork(ctx echo.Context) error { return errorRes(500, "Error incrementing the fork count", err) } + addFlash(ctx, "Gist has been forked", "success") + return redirect(ctx, "/"+currentUser.Username+"/"+newGist.Uuid) }