1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(bug) reload config on change

This commit is contained in:
Sylvain 2023-03-31 11:33:50 +02:00
parent 48d0957bac
commit 2e406aba7f
2 changed files with 15 additions and 2 deletions

View File

@ -10,4 +10,14 @@ class SessionsController < Devise::SessionsController
redirect_post "/users/auth/#{active_provider.strategy_name}"
end
end
# FIXME, Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response.
# def destroy
# active_provider = Rails.configuration.auth_provider
# if active_provider.providable_type == 'OpenIdConnectProvider'
# redirect_to "/users/auth/#{active_provider.strategy_name}/logout"
# else
# super
# end
# end
end

View File

@ -30,7 +30,7 @@ class AuthProvider < ApplicationRecord
validates_with UserUidMappedValidator, if: -> { %w[OAuth2Provider OpenIdConnectProvider].include?(providable_type) }
before_create :set_initial_state
after_update :write_config
after_update :write_reload_config
def build_providable(params)
raise "Unknown providable_type: #{providable_type}" unless PROVIDABLE_TYPES.include?(providable_type)
@ -116,9 +116,12 @@ class AuthProvider < ApplicationRecord
self.status = 'pending' unless AuthProvider.count.zero?
end
def write_config
def write_reload_config
return unless status == 'active'
ProviderConfig.write_active_provider
Rails.application.configure do
config.auth_provider = ProviderConfig.new
end
end
end