Sha256: 6bac88af9cf08b2f2215f4ac71675493c1c6ff97d07f005c5bf2bdaad4a4bc9f

Contents?: true

Size: 1.2 KB

Versions: 81

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Decidim
  # A custom mailer for Devise so we can tweak the invitation instructions for
  # each role and use a localised version.
  class DecidimDeviseMailer < ::Devise::Mailer
    include LocalisedMailer

    layout "decidim/mailer"

    # Sends an email with the invitation instructions to a new user.
    #
    # user  - The User that has been invited.
    # token - The String to be sent as a token to verify the invitation.
    # opts  - A Hash with options to send the email (optional).
    def invitation_instructions(user, token, opts = {})
      with_user(user) do
        @token = token
        @organization = user.organization
        @opts = opts

        opts[:subject] = I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject", organization: user.organization.name) if opts[:invitation_instructions]
      end

      devise_mail(user, opts[:invitation_instructions] || :invitation_instructions, opts)
    end

    private

    # Overwrite devise_mail so we can inject the organization from the user.
    def devise_mail(user, action, opts = {}, &block)
      with_user(user) do
        @organization = user.organization
        super
      end
    end
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.8 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.7 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.6 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.10 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.9 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.5 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.8 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.4 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.3 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.7 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.5 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.2 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.1 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.4 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.0 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.3 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.0.rc2 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.27.0.rc1 app/mailers/decidim/decidim_devise_mailer.rb
decidim-core-0.26.2 app/mailers/decidim/decidim_devise_mailer.rb