1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-18 12:54:27 +01:00

Fix SSO properties not updating

This commit is contained in:
Guilherme Chaguri 2022-07-20 16:28:17 -03:00
parent 27d71dcffd
commit fda93cb7df

View File

@ -40,7 +40,7 @@ module SingleSignOnConcern
## @param sso_mapping {String} must be of form 'user._field_' or 'profile._field_'. Eg. 'user.email'
## @param data {*} the data to put in the given key. Eg. 'user@example.com'
def set_data_from_sso_mapping(sso_mapping, data)
return if data.nil? || data.blank? || mapped_from_sso&.include?(sso_mapping)
return if data.nil? || data.blank?
if sso_mapping.to_s.start_with? 'user.'
self[sso_mapping[5..-1].to_sym] = data
@ -73,6 +73,8 @@ module SingleSignOnConcern
end
end
return if mapped_from_sso&.include?(sso_mapping)
self.mapped_from_sso = [mapped_from_sso, sso_mapping].compact.join(',')
end
@ -122,7 +124,7 @@ module SingleSignOnConcern
logger.debug "mapping sso field #{field} with value=#{value}"
# we do not merge the email field if its end with the special value '-duplicate' as this means
# that the user is currently merging with the account that have the same email than the sso
set_data_from_sso_mapping(field, value) unless (field == 'user.email' && value.end_with?('-duplicate')) || (field == 'user.group_id' && user.admin?)
set_data_from_sso_mapping(field, value) unless field == 'user.email' && value.end_with?('-duplicate')
end
# run the account transfer in an SQL transaction to ensure data integrity