Sha256: ad6299e7101ffbeb2c61d60bc94662c8ef499dad2e93c0e93e7a5a74cfc0716f
Contents?: true
Size: 1.17 KB
Versions: 8
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true module Decidim # Shared behaviour for force_users_to_authenticate_before_access_organization module ForceAuthentication extend ActiveSupport::Concern included do before_action :ensure_authenticated!, unless: :allow_unauthorized_path? end private # For Devise helper functions, see: # https://github.com/plataformatec/devise#getting-started # # Breaks the request lifecycle, if user is not authenticated. # Otherwise returns. def ensure_authenticated! return true unless current_organization.force_users_to_authenticate_before_access_organization # Next stop: Let's check whether auth is ok unless user_signed_in? flash[:warning] = t("actions.login_before_access", scope: "decidim.core") store_location_for(:user, request.path) return redirect_to decidim.new_user_session_path end end # Check for all paths that should be allowed even if the user is not yet # authorized def allow_unauthorized_path? # Changing the locale return true if %r{^\/locale}.match?(request.path) || %r{^\/cookies}.match?(request.path) false end end end
Version data entries
8 entries across 8 versions & 1 rubygems