From 80fd25524e13dedbdc3527b32d008de152213a89 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 22 Mar 2022 08:03:22 +0100 Subject: Renamed ctx.User to ctx.Doer. (#19161) Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang --- routers/api/v1/user/key.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'routers/api/v1/user/key.go') 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) { -- cgit v1.2.3