mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
Disable self-fork
This commit is contained in:
parent
0f42ef01b0
commit
12625ed462
1 changed files with 7 additions and 0 deletions
|
@ -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 a new issue