summaryrefslogtreecommitdiffstats
path: root/models/publickey.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-05 17:13:13 -0500
committerUnknwon <u@gogs.io>2015-12-05 17:13:13 -0500
commit978dc00305f1af705ae8900977529bac6fa4c72b (patch)
tree67587da091f590282fd2c120197249fd9b07b98f /models/publickey.go
parentbf26808fb3fd55d74089e4f758aaac77be56f7ea (diff)
downloadgitea-978dc00305f1af705ae8900977529bac6fa4c72b.tar.gz
gitea-978dc00305f1af705ae8900977529bac6fa4c72b.zip
APIs: admin users
Diffstat (limited to 'models/publickey.go')
-rw-r--r--models/publickey.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/models/publickey.go b/models/publickey.go
index ac0ec71f44..6838947814 100644
--- a/models/publickey.go
+++ b/models/publickey.go
@@ -460,7 +460,7 @@ func DeletePublicKey(doer *User, id int64) (err error) {
}
// Check if user has access to delete this key.
- if doer.Id != key.OwnerID {
+ if !doer.IsAdmin && doer.Id != key.OwnerID {
return ErrKeyAccessDenied{doer.Id, key.ID, "public"}
}
@@ -672,15 +672,17 @@ func DeleteDeployKey(doer *User, id int64) error {
}
// Check if user has access to delete this key.
- repo, err := GetRepositoryByID(key.RepoID)
- if err != nil {
- return fmt.Errorf("GetRepositoryByID: %v", err)
- }
- yes, err := HasAccess(doer, repo, ACCESS_MODE_ADMIN)
- if err != nil {
- return fmt.Errorf("HasAccess: %v", err)
- } else if !yes {
- return ErrKeyAccessDenied{doer.Id, key.ID, "deploy"}
+ if !doer.IsAdmin {
+ repo, err := GetRepositoryByID(key.RepoID)
+ if err != nil {
+ return fmt.Errorf("GetRepositoryByID: %v", err)
+ }
+ yes, err := HasAccess(doer, repo, ACCESS_MODE_ADMIN)
+ if err != nil {
+ return fmt.Errorf("HasAccess: %v", err)
+ } else if !yes {
+ return ErrKeyAccessDenied{doer.Id, key.ID, "deploy"}
+ }
}
sess := x.NewSession()