@@ -10,6 +10,7 @@ import (
10
10
11
11
asymkey_model "code.gitea.io/gitea/models/asymkey"
12
12
"code.gitea.io/gitea/models/db"
13
+ "code.gitea.io/gitea/modules/setting"
13
14
api "code.gitea.io/gitea/modules/structs"
14
15
"code.gitea.io/gitea/modules/web"
15
16
"code.gitea.io/gitea/routers/api/v1/utils"
@@ -132,6 +133,11 @@ func GetGPGKey(ctx *context.APIContext) {
132
133
133
134
// CreateUserGPGKey creates new GPG key to given user by ID.
134
135
func 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
+
135
141
token := asymkey_model .VerificationToken (ctx .Doer , 1 )
136
142
lastToken := asymkey_model .VerificationToken (ctx .Doer , 0 )
137
143
@@ -268,6 +274,11 @@ func DeleteGPGKey(ctx *context.APIContext) {
268
274
// "404":
269
275
// "$ref": "#/responses/notFound"
270
276
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
+
271
282
if err := asymkey_model .DeleteGPGKey (ctx , ctx .Doer , ctx .ParamsInt64 (":id" )); err != nil {
272
283
if asymkey_model .IsErrGPGKeyAccessDenied (err ) {
273
284
ctx .Error (http .StatusForbidden , "" , "You do not have access to this key" )
0 commit comments