aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/serv.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/serv.go')
-rw-r--r--cmd/serv.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/cmd/serv.go b/cmd/serv.go
index 21a69b24d6..ca0354d06c 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -234,19 +234,20 @@ func runServ(c *cli.Context) error {
// Check deploy key or user key.
if key.Type == models.KeyTypeDeploy {
- if key.Mode < requestedMode {
- fail("Key permission denied", "Cannot push with deployment key: %d", key.ID)
- }
-
- // Check if this deploy key belongs to current repository.
- has, err := private.HasDeployKey(key.ID, repo.ID)
+ // Now we have to get the deploy key for this repo
+ deployKey, err := private.GetDeployKey(key.ID, repo.ID)
if err != nil {
fail("Key access denied", "Failed to access internal api: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
}
- if !has {
+
+ if deployKey == nil {
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
}
+ if deployKey.Mode < requestedMode {
+ fail("Key permission denied", "Cannot push with read-only deployment key: %d to repo_id: %d", key.ID, repo.ID)
+ }
+
// Update deploy key activity.
if err = private.UpdateDeployKeyUpdated(key.ID, repo.ID); err != nil {
fail("Internal error", "UpdateDeployKey: %v", err)