Sha256: a8138479c9bbd4d7276d82f3dde3c9879391283117328fe486fcade762b7f8c9

Contents?: true

Size: 716 Bytes

Versions: 5

Compression:

Stored size: 716 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Devise
    # Custom Devise SessionsController to avoid namespace problems.
    class SessionsController < ::Devise::SessionsController
      include Decidim::DeviseControllers

      def after_sign_in_path_for(user)
        return first_login_authorizations_path if first_login_and_not_authorized?(user) &&
                                                  !user.admin?
        super
      end

      def first_login_and_not_authorized?(user)
        user.is_a?(User) && user.sign_in_count == 1 && current_organization.available_authorizations.any?
      end

      def after_sign_out_path_for(user)
        request.referer || super
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.7.4 app/controllers/decidim/devise/sessions_controller.rb
decidim-core-0.7.3 app/controllers/decidim/devise/sessions_controller.rb
decidim-core-0.7.2 app/controllers/decidim/devise/sessions_controller.rb
decidim-core-0.7.1 app/controllers/decidim/devise/sessions_controller.rb
decidim-core-0.7.0 app/controllers/decidim/devise/sessions_controller.rb