From 1c57f0f241c1c8ca449b2f14baa0234f7d2e8548 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Wed, 18 Apr 2018 16:26:39 +0100 Subject: [PATCH] Update :return_url value when re-sending email confirmations --- .../controllers/authentication/forgot_controller.js.coffee | 2 +- .../controllers/authentication/login_controller.js.coffee | 2 +- app/controllers/user_confirmations_controller.rb | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/authentication/forgot_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/authentication/forgot_controller.js.coffee index b2984fd092..7c3b67d823 100644 --- a/app/assets/javascripts/darkswarm/controllers/authentication/forgot_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/authentication/forgot_controller.js.coffee @@ -13,7 +13,7 @@ Darkswarm.controller "ForgotCtrl", ($scope, $http, $location, AuthenticationServ $scope.errors = t 'email_required' $scope.resend_confirmation = -> - $http.post("/user/spree_user/confirmation", {spree_user: $scope.spree_user}).success (data)-> + $http.post("/user/spree_user/confirmation", {spree_user: $scope.spree_user, return_url: $location.absUrl()}).success (data)-> $scope.messages = t('devise.confirmations.send_instructions') .error (data) -> $scope.errors = t('devise.confirmations.failed_to_send') diff --git a/app/assets/javascripts/darkswarm/controllers/authentication/login_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/authentication/login_controller.js.coffee index 016d60d9d2..f1bb13bcca 100644 --- a/app/assets/javascripts/darkswarm/controllers/authentication/login_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/authentication/login_controller.js.coffee @@ -14,7 +14,7 @@ Darkswarm.controller "LoginCtrl", ($scope, $timeout, $location, $http, $window, $scope.user_unconfirmed = (data.error == t('devise.failure.unconfirmed')) $scope.resend_confirmation = -> - $http.post("/user/spree_user/confirmation", {spree_user: $scope.spree_user}).success (data)-> + $http.post("/user/spree_user/confirmation", {spree_user: $scope.spree_user, return_url: $location.absUrl()}).success (data)-> $scope.messages = t('devise.confirmations.send_instructions') .error (data) -> $scope.errors = t('devise.confirmations.failed_to_send') diff --git a/app/controllers/user_confirmations_controller.rb b/app/controllers/user_confirmations_controller.rb index 8e3e504eaa..e564da0b64 100644 --- a/app/controllers/user_confirmations_controller.rb +++ b/app/controllers/user_confirmations_controller.rb @@ -8,6 +8,7 @@ class UserConfirmationsController < DeviseController # POST /resource/confirmation def create + set_return_url if params.key? :return_url self.resource = resource_class.send_confirmation_instructions(resource_params) if is_navigational_format? @@ -30,6 +31,10 @@ class UserConfirmationsController < DeviseController protected + def set_return_url + session[:confirmation_return_url] = params[:return_url] + end + def after_confirmation_path_for(resource) result = if resource.errors.empty?