Sha256: bd1d48a9d1abf691f5b442fcd384ecc22cdd4f171b2a66ae71e888362b0b6e80

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # This concern groups methods and helpers needed by Devise controllers.
  module DeviseControllers
    extend ActiveSupport::Concern

    included do
      include Decidim::NeedsOrganization
      include Decidim::LocaleSwitcher
      include ImpersonateUsers
      include NeedsAuthorization

      skip_authorization_check

      helper Decidim::TranslationsHelper
      helper Decidim::MetaTagsHelper
      helper Decidim::DecidimFormHelper
      helper Decidim::LanguageChooserHelper
      helper Decidim::CookiesHelper
      helper Decidim::ReplaceButtonsHelper
      helper Decidim::LayoutHelper
      helper Decidim::MenuHelper
      helper Decidim::OmniauthHelper

      layout "layouts/decidim/application"

      # Saves the location before loading each page so we can return to the
      # right page.
      before_action :store_current_location
    end

    # Overwrites `cancancan`'s method to point to the correct ability class,
    # since the gem expects the ability class to be in the root namespace.
    def current_ability_klass
      Decidim::Abilities::BaseAbility
    end

    def store_current_location
      return if params[:redirect_url].blank? || !request.format.html?

      store_location_for(:user, params[:redirect_url])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.11.2 app/controllers/concerns/decidim/devise_controllers.rb
decidim-core-0.11.1 app/controllers/concerns/decidim/devise_controllers.rb
decidim-core-0.11.0.pre1 app/controllers/concerns/decidim/devise_controllers.rb