+
\ No newline at end of file
diff --git a/app/assets/templates/admin/authentications/_oauth2_mapping.html.erb b/app/assets/templates/admin/authentications/_oauth2_mapping.html.erb
index bb16e52f1..4785bdb72 100644
--- a/app/assets/templates/admin/authentications/_oauth2_mapping.html.erb
+++ b/app/assets/templates/admin/authentications/_oauth2_mapping.html.erb
@@ -16,11 +16,14 @@
{{m.local_model}}
-
{{m.local_field}}
+
{{m.local_field[0]}}
{{m.api_endpoint}}
{{m.api_data_type}}
{{m.api_field}}
+
@@ -38,7 +41,7 @@
diff --git a/app/models/profile.rb b/app/models/profile.rb
index aa3097f4c..483fbee71 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -37,4 +37,16 @@ class Profile < ActiveRecord::Base
def str_gender
gender ? 'male' : 'female'
end
+
+ def self.mapping
+ # 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)]
+ Profile.column_types
+ .map{|k,v| [k, v.type.to_s]}
+ .delete_if { |col| blacklist.include?(col[0]) }
+ .concat(additional)
+ end
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 2985cad0c..af040ab7c 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -336,6 +336,17 @@ class User < ActiveRecord::Base
end
end
+ def self.mapping
+ # we protect some fields as they are designed to be managed by the system and must not be updated externally
+ blacklist = %w(id encrypted_password reset_password_token reset_password_sent_at remember_created_at
+ sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip confirmation_token confirmed_at
+ confirmation_sent_at unconfirmed_email failed_attempts unlock_token locked_at created_at updated_at stp_customer_id slug
+ provider auth_token merged_at)
+ User.column_types
+ .map{|k,v| [k, v.type.to_s]}
+ .delete_if { |col| blacklist.include?(col[0]) }
+ end
+
protected
def confirmation_required?
false
diff --git a/app/views/api/auth_providers/mapping_fields.json.jbuilder b/app/views/api/auth_providers/mapping_fields.json.jbuilder
index b2683f523..7eb9615bf 100644
--- a/app/views/api/auth_providers/mapping_fields.json.jbuilder
+++ b/app/views/api/auth_providers/mapping_fields.json.jbuilder
@@ -1,9 +1,4 @@
-# we protect some fields are they are designed to be managed by the system and must not be updated externally
+json.user User.mapping
-json.user User.column_names - %w(id encrypted_password reset_password_token reset_password_sent_at remember_created_at
-sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip confirmation_token confirmed_at
-confirmation_sent_at unconfirmed_email failed_attempts unlock_token locked_at created_at updated_at stp_customer_id slug
-provider auth_token merged_at)
-
-json.profile Profile.column_names - %w(id user_id created_at updated_at) + %w(avatar address organization_name organization_address)
\ No newline at end of file
+json.profile Profile.mapping
\ No newline at end of file
diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml
index 34de8a913..1014fc37c 100644
--- a/config/locales/app.shared.en.yml
+++ b/config/locales/app.shared.en.yml
@@ -248,6 +248,8 @@ en:
provider_name_is_required: "Provider name is required."
authentication_type: "Authentication type"
authentication_type_is_required: "Authentication type is required."
+ data_mapping: "Data mapping"
+ expected_data_type: "Expected data type"
oauth2:
# edition/creation form of an OAuth2 authentication provider
diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml
index a6c7afc6f..b21ebb954 100644
--- a/config/locales/app.shared.fr.yml
+++ b/config/locales/app.shared.fr.yml
@@ -248,6 +248,8 @@ fr:
provider_name_is_required: "Le nom du fournisseur est requis."
authentication_type: "Type d'authentification"
authentication_type_is_required: "Le type d'authentification est requis."
+ data_mapping: "Correspondance des données"
+ expected_data_type: "Type de données attendues"
oauth2:
# formulaire d'édition/création d'un fournisseur d'authentification de type OAuth2