mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	Per #14531, deleting a user account will delete the user's GPG keys from the `gpg_key` table but not from `gpg_key_import`, which causes an error when creating an account with the same email and attempting to re-add the same key. This commit deletes all entries from `gpg_key_import` that match any GPG key IDs belonging to the user. Co-authored-by: Anton Khimich <anton.khimicha@mail.utoronto.ca>
This commit is contained in:
		| @@ -65,7 +65,11 @@ func (key *GPGKey) AfterLoad(session *xorm.Session) { | ||||
|  | ||||
| // ListGPGKeys returns a list of public keys belongs to given user. | ||||
| func ListGPGKeys(uid int64, listOptions ListOptions) ([]*GPGKey, error) { | ||||
| 	sess := x.Where("owner_id=? AND primary_key_id=''", uid) | ||||
| 	return listGPGKeys(x, uid, listOptions) | ||||
| } | ||||
|  | ||||
| func listGPGKeys(e Engine, uid int64, listOptions ListOptions) ([]*GPGKey, error) { | ||||
| 	sess := e.Table(&GPGKey{}).Where("owner_id=? AND primary_key_id=''", uid) | ||||
| 	if listOptions.Page != 0 { | ||||
| 		sess = listOptions.setSessionPagination(sess) | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user