diff --git a/app/controllers/concerns/decidim/devise/sessions_controller_override.rb b/app/controllers/concerns/decidim/devise/sessions_controller_override.rb new file mode 100644 index 0000000..bf5f0aa --- /dev/null +++ b/app/controllers/concerns/decidim/devise/sessions_controller_override.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Decidim + module Devise + module SessionsControllerOverride + extend ActiveSupport::Concern + + included do + alias_method :original_after_sign_out_path_for, :after_sign_out_path_for + alias_method :original_destroy, :destroy + + def destroy + @user = current_user + original_destroy + end + + def after_sign_out_path_for(resource) + url = ENV.fetch("ODOO_SIGN_OUT_URL", nil) + if @user.odoo_identity? && url + url + else + original_after_sign_out_path_for(resource) + end + end + end + end + end +end diff --git a/config/initializers/decidim_overrides.rb b/config/initializers/decidim_overrides.rb index 838978f..77e8c0c 100644 --- a/config/initializers/decidim_overrides.rb +++ b/config/initializers/decidim_overrides.rb @@ -4,6 +4,7 @@ Decidim::ActionDelegator::Verifications::DelegationsVerifier::AuthorizationsController.include( Decidim::ActionDelegator::Verifications::DelegationsVerifier::AuthorizationsControllerOverride ) + Decidim::Devise::SessionsController.include(Decidim::Devise::SessionsControllerOverride) Decidim::ActionDelegator::Setting.include(Decidim::ActionDelegator::SettingOverride) Decidim::ActionDelegator::Verifications::DelegationsAuthorizer.include(Decidim::ActionDelegator::Verifications::DelegationsAuthorizerOverride) Decidim::Odoo::Verifications::OdooMember.include(Decidim::Odoo::Verifications::OdooMemberOverride) diff --git a/spec/lib/overrides_spec.rb b/spec/lib/overrides_spec.rb index a546be9..9865796 100644 --- a/spec/lib/overrides_spec.rb +++ b/spec/lib/overrides_spec.rb @@ -9,6 +9,7 @@ { package: "decidim-core", files: { + "/app/controllers/decidim/devise/sessions_controller.rb" => "235cbe9844cdd39f65c72d3dc87f5f23", "/app/views/layouts/decidim/_head_extra.html.erb" => "1b8237357754cf519f4e418135f78440" } },