diff --git a/models/asymkey/gpg_key.go b/models/asymkey/gpg_key.go index 7f35a96a59..62fdc3c64b 100644 --- a/models/asymkey/gpg_key.go +++ b/models/asymkey/gpg_key.go @@ -163,13 +163,17 @@ func parseGPGKey(ctx context.Context, ownerID int64, e *openpgp.Entity, verified if ident.Revoked(time.Now()) { continue } - email := strings.ToLower(strings.TrimSpace(ident.UserId.Email)) + emailAddr := &user_model.EmailAddress{ + Email: ident.UserId.Email, + LowerEmail: strings.ToLower(strings.TrimSpace(ident.UserId.Email)), + IsActivated: false, + } for _, e := range userEmails { - if e.IsActivated && e.LowerEmail == email { - emails = append(emails, e) - break + if e.LowerEmail == emailAddr.LowerEmail { + emailAddr.IsActivated = true } } + emails = append(emails, emailAddr) } if !verified { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index bce64a81a3..1db86cdb95 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -839,6 +839,7 @@ add_new_principal = Add Principal ssh_key_been_used = This SSH key has already been added to the server. ssh_key_name_used = An SSH key with same name already exists on your account. ssh_principal_been_used = This principal has already been added to the server. +gpg_email_unverified = Unverified gpg_key_id_used = A public GPG key with same ID already exists. gpg_no_key_email_found = This GPG key does not match any activated email address associated with your account. It may still be added if you sign the provided token. gpg_key_matched_identities = Matched Identities: diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index e44a838b25..6a167e008e 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -56,7 +56,7 @@ {{svg "octicon-verified"}} {{ctx.Locale.Tr "settings.gpg_key_verified"}} {{end}} {{if .Emails}} - {{svg "octicon-mail"}} {{ctx.Locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}{{.Email}} {{end}} + {{svg "octicon-mail"}} {{ctx.Locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}{{.Email}} {{if not .IsActivated}}{{ctx.Locale.Tr "settings.gpg_email_unverified"}}{{end}}{{end}} {{end}}
{{ctx.Locale.Tr "settings.key_id"}}: {{.PaddedKeyID}}