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

(api) save which data is really mapped from the sso

This commit is contained in:
Sylvain 2022-04-25 12:23:58 +02:00
parent 0dd6f4bff5
commit 6f80025adb
5 changed files with 19 additions and 4 deletions

View File

@ -15,6 +15,7 @@ export interface User {
name: string,
need_completion: boolean,
ip_address: string,
mapped_from_sso?: string[],
profile: {
id: number,
first_name: string,

View File

@ -21,11 +21,11 @@ module SingleSignOnConcern
when 'profile.avatar'
profile.user_avatar.remote_attachment_url
when 'profile.address'
invoicing_profile.address.address
invoicing_profile.address&.address
when 'profile.organization_name'
invoicing_profile.organization.name
invoicing_profile.organization&.name
when 'profile.organization_address'
invoicing_profile.organization.address.address
invoicing_profile.organization&.address&.address
when 'profile.gender'
statistic_profile.gender
when 'profile.birthday'
@ -70,6 +70,9 @@ module SingleSignOnConcern
profile[sso_mapping[8..-1].to_sym] = data unless data.nil?
end
end
return if data.nil? || mapped_from_sso.include?(sso_mapping)
self.mapped_from_sso = [mapped_from_sso, sso_mapping].compact.join(',')
end
## used to allow the migration of existing users between authentication providers

View File

@ -5,6 +5,7 @@ json.role member.roles.first.name
json.name member.profile.full_name
json.need_completion member.need_completion?
json.ip_address member.current_sign_in_ip.to_s
json.mapped_from_sso member.mapped_from_sso&.split(',')
json.profile do
json.id member.profile.id

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
# We save the data provided by the SSO provider in the user table. So we know,
# per user which data was provided or not.
class AddMappedFromSsoToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :mapped_from_sso, :string
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_03_28_145017) do
ActiveRecord::Schema.define(version: 2022_04_25_095244) do
# These are extensions that must be enabled in order to support this database
enable_extension "fuzzystrmatch"
@ -963,6 +963,7 @@ ActiveRecord::Schema.define(version: 2022_03_28_145017) do
t.boolean "is_allow_newsletter"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.string "mapped_from_sso"
t.index ["auth_token"], name: "index_users_on_auth_token"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true