summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/key.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-03-22 08:03:22 +0100
committerGitHub <noreply@github.com>2022-03-22 15:03:22 +0800
commit80fd25524e13dedbdc3527b32d008de152213a89 (patch)
tree63b2bfe4ffaf1dce12080cabdc2e845c8731a673 /routers/api/v1/user/key.go
parent5495ba7660979973ba19e304786135da474e0e64 (diff)
downloadgitea-80fd25524e13dedbdc3527b32d008de152213a89.tar.gz
gitea-80fd25524e13dedbdc3527b32d008de152213a89.zip
Renamed ctx.User to ctx.Doer. (#19161)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/api/v1/user/key.go')
-rw-r--r--routers/api/v1/user/key.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index e8cc2035e5..67ffec723d 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -86,7 +86,7 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
apiKeys := make([]*api.PublicKey, len(keys))
for i := range keys {
apiKeys[i] = convert.ToPublicKey(apiLink, keys[i])
- if ctx.User.IsAdmin || ctx.User.ID == keys[i].OwnerID {
+ if ctx.Doer.IsAdmin || ctx.Doer.ID == keys[i].OwnerID {
apiKeys[i], _ = appendPrivateInformation(apiKeys[i], keys[i], user)
}
}
@@ -119,7 +119,7 @@ func ListMyPublicKeys(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/PublicKeyList"
- listPublicKeys(ctx, ctx.User)
+ listPublicKeys(ctx, ctx.Doer)
}
// ListPublicKeys list the given user's public keys
@@ -190,8 +190,8 @@ func GetPublicKey(ctx *context.APIContext) {
apiLink := composePublicKeysAPILink()
apiKey := convert.ToPublicKey(apiLink, key)
- if ctx.User.IsAdmin || ctx.User.ID == key.OwnerID {
- apiKey, _ = appendPrivateInformation(apiKey, key, ctx.User)
+ if ctx.Doer.IsAdmin || ctx.Doer.ID == key.OwnerID {
+ apiKey, _ = appendPrivateInformation(apiKey, key, ctx.Doer)
}
ctx.JSON(http.StatusOK, apiKey)
}
@@ -211,8 +211,8 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
}
apiLink := composePublicKeysAPILink()
apiKey := convert.ToPublicKey(apiLink, key)
- if ctx.User.IsAdmin || ctx.User.ID == key.OwnerID {
- apiKey, _ = appendPrivateInformation(apiKey, key, ctx.User)
+ if ctx.Doer.IsAdmin || ctx.Doer.ID == key.OwnerID {
+ apiKey, _ = appendPrivateInformation(apiKey, key, ctx.Doer)
}
ctx.JSON(http.StatusCreated, apiKey)
}
@@ -238,7 +238,7 @@ func CreatePublicKey(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.CreateKeyOption)
- CreateUserPublicKey(ctx, *form, ctx.User.ID)
+ CreateUserPublicKey(ctx, *form, ctx.Doer.ID)
}
// DeletePublicKey delete one public key
@@ -272,7 +272,7 @@ func DeletePublicKey(ctx *context.APIContext) {
ctx.Error(http.StatusForbidden, "", "SSH Key is externally managed for this user")
}
- if err := asymkey_service.DeletePublicKey(ctx.User, id); err != nil {
+ if err := asymkey_service.DeletePublicKey(ctx.Doer, id); err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
ctx.NotFound()
} else if asymkey_model.IsErrKeyAccessDenied(err) {