Update LDAP mail attribute when re-confirming email

This commit is contained in:
Râu Cao 2023-05-25 16:55:27 +02:00
parent 61f12c2741
commit 7b321577db
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
3 changed files with 25 additions and 5 deletions

View File

@ -58,6 +58,11 @@ class User < ApplicationRecord
end
def devise_after_confirmation
if ldap_entry[:mail] != self.email
# E-Mail update confirmed
LdapManager::UpdateEmail.call(self.dn, self.email)
else
# E-Mail from signup confirmed (i.e. account activation)
enable_service %w[ discourse gitea mediawiki xmpp ]
#TODO enable in development when we have easy setup of ejabberd etc.
@ -66,6 +71,7 @@ class User < ApplicationRecord
XmppExchangeContactsJob.perform_later(inviter, self) if inviter.present?
XmppSetDefaultBookmarksJob.perform_later(self)
end
end
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later

View File

@ -0,0 +1,12 @@
module LdapManager
class UpdateEmail < LdapManagerService
def initialize(dn, address)
@dn = dn
@address = address
end
def call
replace_attribute @dn, :mail, [ @address ]
end
end
end

View File

@ -0,0 +1,2 @@
class LdapManagerService < LdapService
end