Sha256: 6dad55acb2af4488a6af6bc6d871d908651eebcb43032a7eb12a78b80fc58bb7

Contents?: true

Size: 983 Bytes

Versions: 13

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The controller to manage email confirmations for user groups.
  class GroupEmailConfirmationsController < Decidim::ApplicationController
    include FormFactory
    include UserGroups

    before_action :enforce_user_groups_enabled

    helper_method :user_group

    def create
      enforce_permission_to(:manage, :user_group, user_group:)
      if user_group.email.blank?
        flash.keep[:alert] = t("decidim.profiles.user.fill_in_email_to_confirm_it")
        redirect_to(edit_group_path(user_group.nickname)) && return
      end

      user_group.send_confirmation_instructions

      flash.keep[:notice] = t("decidim.profiles.user.confirmation_instructions_sent")
      redirect_back(fallback_location: decidim.profile_path(user_group.nickname))
    end

    private

    def user_group
      @user_group ||= Decidim::UserGroups::ManageableUserGroups.for(current_user).find_by(nickname: params[:group_id])
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.4 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.29.0 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.3 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.29.0.rc4 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.29.0.rc3 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.29.0.rc2 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.29.0.rc1 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.2 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.1 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.0 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.0.rc5 app/controllers/decidim/group_email_confirmations_controller.rb
decidim-core-0.28.0.rc4 app/controllers/decidim/group_email_confirmations_controller.rb