1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

[bug] unable to bind sso to Profile.bithday or Profile.gender

This commit is contained in:
Sylvain 2021-12-20 14:07:25 +01:00
parent 587beb01ab
commit 3fb9850786
3 changed files with 14 additions and 3 deletions

View File

@ -27,7 +27,8 @@ class Profile < ApplicationRecord
# we protect some fields as they are designed to be managed by the system and must not be updated externally
blacklist = %w[id user_id created_at updated_at]
# model-relationships must be added manually
additional = [%w[avatar string], %w[address string], %w[organization_name string], %w[organization_address string]]
additional = [%w[avatar string], %w[address string], %w[organization_name string], %w[organization_address string],
%w[gender boolean], %w[birthday date]]
Profile.columns_hash
.map { |k, v| [k, v.type.to_s] }
.delete_if { |col| blacklist.include?(col[0]) }

View File

@ -242,6 +242,10 @@ class User < ApplicationRecord
invoicing_profile.organization.name
when 'profile.organization_address'
invoicing_profile.organization.address.address
when 'profile.gender'
statistic_profile.gender
when 'profile.birthday'
statistic_profile.birthday
else
profile[parsed[2].to_sym]
end
@ -269,6 +273,12 @@ class User < ApplicationRecord
invoicing_profile.organization ||= Organization.new
invoicing_profile.organization.address ||= Address.new
invoicing_profile.organization.address.address = data
when 'profile.gender'
statistic_profile ||= StatisticProfile.new
statistic_profile.gender = data
when 'profile.birthday'
statistic_profile ||= StatisticProfile.new
statistic_profile.birthday = data
else
profile[sso_mapping[8..-1].to_sym] = data unless data.nil?
end

View File

@ -1,4 +1,4 @@
# frozen_string_literal: true
json.user User.mapping
json.profile Profile.mapping
json.profile Profile.mapping