Skip to content
Snippets Groups Projects
Unverified Commit 7ac5fa21 authored by Pierre-André Boissinot's avatar Pierre-André Boissinot Committed by GitHub
Browse files

Merge pull request #1342 from noesya/sync_server_admin_deletion

La destruction d'un utilisateur Server Admin le supprime dans toutes les universités
parents 1bb01580 ce6cedd2
No related branches found
No related tags found
Loading
......@@ -5,6 +5,7 @@ module User::WithSyncBetweenUniversities
attr_accessor :skip_server_admin_sync
after_save :sync_between_universities, if: Proc.new { |user| user.server_admin? && !user.skip_server_admin_sync }
after_destroy :remove_from_all_universities, if: Proc.new { |user| user.server_admin? }
def self.synchronize_server_admin_users(source_university, target_university)
source_university.users.server_admin.each do |user|
......@@ -48,4 +49,9 @@ module User::WithSyncBetweenUniversities
user.update_column(:encrypted_password, self.encrypted_password) if user.valid?
end
def remove_from_all_universities
# As a "server_admin" is synced between universities, any removal destroys the accounts of the concerned user in every university
User.where(email: email, role: :server_admin).destroy_all
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment