summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--integrations/user_test.go1
-rw-r--r--routers/web/user/home.go3
2 files changed, 4 insertions, 0 deletions
diff --git a/integrations/user_test.go b/integrations/user_test.go
index c12c2be40e..4cfe7700e1 100644
--- a/integrations/user_test.go
+++ b/integrations/user_test.go
@@ -121,6 +121,7 @@ func TestExportUserGPGKeys(t *testing.T) {
defer prepareTestEnv(t)()
// Export empty key list
testExportUserGPGKeys(t, "user1", `-----BEGIN PGP PUBLIC KEY BLOCK-----
+Note: This user hasn't uploaded any GPG keys.
=twTO
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 33512d97c0..379e1f8e20 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -736,6 +736,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
ctx.ServerError("ListGPGKeys", err)
return
}
+
entities := make([]*openpgp.Entity, 0)
failedEntitiesID := make([]string, 0)
for _, k := range keys {
@@ -755,6 +756,8 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
headers := make(map[string]string)
if len(failedEntitiesID) > 0 { // If some key need re-import to be exported
headers["Note"] = fmt.Sprintf("The keys with the following IDs couldn't be exported and need to be reuploaded %s", strings.Join(failedEntitiesID, ", "))
+ } else if len(entities) == 0 {
+ headers["Note"] = "This user hasn't uploaded any GPG keys."
}
writer, _ := armor.Encode(&buf, "PGP PUBLIC KEY BLOCK", headers)
for _, e := range entities {