@@ -10,6 +10,7 @@ import (
1010
1111 asymkey_model "code.gitea.io/gitea/models/asymkey"
1212 "code.gitea.io/gitea/models/db"
13+ "code.gitea.io/gitea/modules/setting"
1314 api "code.gitea.io/gitea/modules/structs"
1415 "code.gitea.io/gitea/modules/web"
1516 "code.gitea.io/gitea/routers/api/v1/utils"
@@ -132,6 +133,11 @@ func GetGPGKey(ctx *context.APIContext) {
132133
133134// CreateUserGPGKey creates new GPG key to given user by ID.
134135func CreateUserGPGKey (ctx * context.APIContext , form api.CreateGPGKeyOption , uid int64 ) {
136+ if setting .Admin .UserDisabledFeatures .Contains (setting .UserFeatureManageGPGKeys ) {
137+ ctx .NotFound ("Not Found" , fmt .Errorf ("gpg keys setting is not allowed to be visited" ))
138+ return
139+ }
140+
135141 token := asymkey_model .VerificationToken (ctx .Doer , 1 )
136142 lastToken := asymkey_model .VerificationToken (ctx .Doer , 0 )
137143
@@ -268,6 +274,11 @@ func DeleteGPGKey(ctx *context.APIContext) {
268274 // "404":
269275 // "$ref": "#/responses/notFound"
270276
277+ if setting .Admin .UserDisabledFeatures .Contains (setting .UserFeatureManageGPGKeys ) {
278+ ctx .NotFound ("Not Found" , fmt .Errorf ("gpg keys setting is not allowed to be visited" ))
279+ return
280+ }
281+
271282 if err := asymkey_model .DeleteGPGKey (ctx , ctx .Doer , ctx .ParamsInt64 (":id" )); err != nil {
272283 if asymkey_model .IsErrGPGKeyAccessDenied (err ) {
273284 ctx .Error (http .StatusForbidden , "" , "You do not have access to this key" )
0 commit comments