diff --git a/app/mailers/enterprise_mailer.rb b/app/mailers/enterprise_mailer.rb index 73c09e1e56..f5f92aed3f 100644 --- a/app/mailers/enterprise_mailer.rb +++ b/app/mailers/enterprise_mailer.rb @@ -1,10 +1,18 @@ +require 'devise/mailers/helpers' class EnterpriseMailer < Spree::BaseMailer + include Devise::Mailers::Helpers + def creation_confirmation(enterprise) find_enterprise(enterprise) subject = "#{@enterprise.name} is now on #{Spree::Config[:site_name]}" mail(:to => @enterprise.owner.email, :from => from_address, :subject => subject) end + def confirmation_instructions(record, token, opts={}) + @token = token + devise_mail(record, :confirmation_instructions, opts) + end + private def find_enterprise(enterprise) @enterprise = enterprise.is_a?(Enterprise) ? enterprise : Enterprise.find(enterprise) diff --git a/app/mailers/spree/user_mailer_decorator.rb b/app/mailers/spree/user_mailer_decorator.rb index ff8bdc4691..dd21a3d0d7 100644 --- a/app/mailers/spree/user_mailer_decorator.rb +++ b/app/mailers/spree/user_mailer_decorator.rb @@ -1,5 +1,5 @@ Spree::UserMailer.class_eval do - + def signup_confirmation(user) @user = user mail(:to => user.email, :from => from_address, diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index e5b92b0382..411f144f13 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -262,6 +262,12 @@ class Enterprise < ActiveRecord::Base select('DISTINCT spree_taxons.*') end + protected + + def devise_mailer + EnterpriseMailer + end + private def send_creation_email diff --git a/app/views/enterprise_mailer/confirmation_instructions.html.haml b/app/views/enterprise_mailer/confirmation_instructions.html.haml new file mode 100644 index 0000000000..277e27aae5 --- /dev/null +++ b/app/views/enterprise_mailer/confirmation_instructions.html.haml @@ -0,0 +1,5 @@ +%p= "Welcome #{@resource.contact}!" + +%p= "You can confirm this email address for #{@resource.name} using the link below:" + +%p= link_to 'Confirm this email address', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3e063641dd..9cdac4142d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,8 @@ Openfoodnetwork::Application.routes.draw do end end + devise_for :enterprise + namespace :admin do resources :order_cycles do post :bulk_update, on: :collection, as: :bulk_update