Not sure if you have a suggestion label, but instead of looping over the users .enc files until one works, the user "name" or email could be matched by checking the fingerprints of the key and the users public key fingerprints. Something like:
for (pubkey in dir('vault/users/' pattern='.pem$')) {
pubkeyfile = file.path('inst', 'vault', 'users', pubkey)
if (as.character(fingerprint(key)) == as.character(fingerprint(read_pubkey(pubkeyfile)))) {
return(pubkey)
}
}
Not sure if you have a suggestion label, but instead of looping over the users .enc files until one works, the user "name" or email could be matched by checking the fingerprints of the key and the users public key fingerprints. Something like: