diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-03-02 09:21:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-02 01:21:01 +0000 |
commit | 9de5e39e25009bacc5ca201ed97e9cbb623e56e9 (patch) | |
tree | 1df6d30974e7b7563d23c22db52533247eb73772 /routers/web/user | |
parent | 85ad4a0f7d3468a2e79270fd36f544202560143b (diff) | |
download | gitea-9de5e39e25009bacc5ca201ed97e9cbb623e56e9.tar.gz gitea-9de5e39e25009bacc5ca201ed97e9cbb623e56e9.zip |
Allow options to disable user gpg keys configuration from the interface on app.ini (#29486)
Follow #29447
Fix #29454
Extract from #20549
Diffstat (limited to 'routers/web/user')
-rw-r--r-- | routers/web/user/setting/keys.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/routers/web/user/setting/keys.go b/routers/web/user/setting/keys.go index 0a12777e5e..cb01913bda 100644 --- a/routers/web/user/setting/keys.go +++ b/routers/web/user/setting/keys.go @@ -5,6 +5,7 @@ package setting import ( + "fmt" "net/http" asymkey_model "code.gitea.io/gitea/models/asymkey" @@ -77,6 +78,11 @@ func KeysPost(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("settings.add_principal_success", form.Content)) ctx.Redirect(setting.AppSubURL + "/user/settings/keys") case "gpg": + if setting.Admin.UserDisabledFeatures.Contains(setting.UserFeatureManageGPGKeys) { + ctx.NotFound("Not Found", fmt.Errorf("gpg keys setting is not allowed to be visited")) + return + } + token := asymkey_model.VerificationToken(ctx.Doer, 1) lastToken := asymkey_model.VerificationToken(ctx.Doer, 0) @@ -224,6 +230,10 @@ func KeysPost(ctx *context.Context) { func DeleteKey(ctx *context.Context) { switch ctx.FormString("type") { case "gpg": + if setting.Admin.UserDisabledFeatures.Contains(setting.UserFeatureManageGPGKeys) { + ctx.NotFound("Not Found", fmt.Errorf("gpg keys setting is not allowed to be visited")) + return + } if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.FormInt64("id")); err != nil { ctx.Flash.Error("DeleteGPGKey: " + err.Error()) } else { |