-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDP-314] Adds user currently chosen store info for mailers
- Loading branch information
Showing
8 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
module Spree | ||
class UserMailer < BaseMailer | ||
def reset_password_instructions(user, token, *_args) | ||
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: Spree::Store.current.url) | ||
@current_store = user&.current_store || Spree::Store.current | ||
@locale = user&.current_store&.default_locale | ||
I18n.locale = @locale if @locale.present? | ||
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @current_store.url) | ||
|
||
mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]) | ||
mail to: user.email, from: from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]) | ||
end | ||
|
||
def confirmation_instructions(user, token, _opts = {}) | ||
@confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: Spree::Store.current.url) | ||
@current_store = user&.current_store || Spree::Store.current | ||
@locale = user&.current_store&.default_locale | ||
I18n.locale = @locale if @locale.present? | ||
@confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: @current_store.url) | ||
@email = user.email | ||
|
||
mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]) | ||
mail to: user.email, from: from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
app/views/spree/user_mailer/confirmation_instructions.text.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Welcome <%= @email %>! | ||
<%= Spree.t('confirmation_instructions.welcome', email: @email) %> | ||
|
||
You can confirm your account email through the url below: | ||
<%= Spree.t('confirmation_instructions.confirm') %> | ||
|
||
<%= @confirmation_url %> | ||
<%= @confirmation_url %> |
9 changes: 2 additions & 7 deletions
9
app/views/spree/user_mailer/reset_password_instructions.text.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
A request to reset your password has been made. | ||
If you did not make this request, simply ignore this email. | ||
|
||
If you did make this request just click the link below: | ||
<%= Spree.t('user_mailer.reset_password_instructions.instructions_1') %> | ||
|
||
<%= @edit_password_reset_url %> | ||
|
||
If the above URL does not work try copying and pasting it into your browser. | ||
If you continue to have problems please feel free to contact us. | ||
|
||
<%= Spree.t('user_mailer.reset_password_instructions.instructions_2') %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddStoreToUser < ActiveRecord::Migration[6.0] | ||
def change | ||
unless column_exists?(:spree_users, :store_id) | ||
add_column :spree_users, :store_id, :integer | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Spree | ||
module Core | ||
module ControllerHelpers | ||
module StoreDecorator | ||
def self.prepended(base) | ||
base.included do | ||
before_action :set_user_current_store | ||
end | ||
end | ||
|
||
def set_user_current_store | ||
return if try_spree_current_user.nil? | ||
|
||
try_spree_current_user.current_store = current_store | ||
try_spree_current_user.save | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
Spree::Core::ControllerHelpers::Store.prepend Spree::Core::ControllerHelpers::StoreDecorator |