|
@@ -45,6 +45,11 @@ func GetDeployKey(c *context.APIContext) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if key.RepoID != c.Repo.Repository.ID {
|
|
|
|
|
+ c.NotFound()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if err = key.GetContent(); err != nil {
|
|
if err = key.GetContent(); err != nil {
|
|
|
c.Error(err, "get content")
|
|
c.Error(err, "get content")
|
|
|
return
|
|
return
|
|
@@ -94,7 +99,18 @@ func CreateDeployKey(c *context.APIContext, form api.CreateKeyOption) {
|
|
|
|
|
|
|
|
// https://github.com/gogs/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
|
// https://github.com/gogs/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
|
|
func DeleteDeploykey(c *context.APIContext) {
|
|
func DeleteDeploykey(c *context.APIContext) {
|
|
|
- if err := database.DeleteDeployKey(c.User, c.ParamsInt64(":id")); err != nil {
|
|
|
|
|
|
|
+ key, err := database.GetDeployKeyByID(c.ParamsInt64(":id"))
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ c.NotFoundOrError(err, "get deploy key by ID")
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if key.RepoID != c.Repo.Repository.ID {
|
|
|
|
|
+ c.NotFound()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if err := database.DeleteDeployKey(c.User, key.ID); err != nil {
|
|
|
if database.IsErrKeyAccessDenied(err) {
|
|
if database.IsErrKeyAccessDenied(err) {
|
|
|
c.ErrorStatus(http.StatusForbidden, errors.New("You do not have access to this key"))
|
|
c.ErrorStatus(http.StatusForbidden, errors.New("You do not have access to this key"))
|
|
|
} else {
|
|
} else {
|