Allow users to update their OpenPGP pubkey
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-23 18:13:39 +02:00
parent 118fddb497
commit 3042a02a17
9 changed files with 193 additions and 10 deletions

View File

@@ -0,0 +1,24 @@
module UserManager
class UpdatePgpKey < UserManagerService
def initialize(user:)
@user = user
end
def call
if @user.pgp_pubkey.blank?
@user.update! pgp_fpr: nil
else
result = GPGME::Key.import(@user.pgp_pubkey)
if result.imports.present?
@user.update! pgp_fpr: result.imports.first.fpr
else
# TODO notify Sentry, user
raise "Failed to import OpenPGP pubkey"
end
end
LdapManager::UpdatePgpKey.call(dn: @user.dn, pubkey: @user.pgp_pubkey)
end
end
end