mirror of
https://github.com/thomiceli/opengist
synced 2024-11-08 12:55:50 +01:00
Disable self-fork
This commit is contained in:
parent
0f42ef01b0
commit
12625ed462
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user