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 ae8841df09..1fb3594f14 100644 --- a/app/assets/javascripts/darkswarm/controllers/authentication/login_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/authentication/login_controller.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.controller "LoginCtrl", ($scope, $http, $window, AuthenticationService, Redirections, Loading) -> +Darkswarm.controller "LoginCtrl", ($scope, $timeout, $location, $http, $window, AuthenticationService, Redirections, Loading) -> $scope.path = "/login" $scope.submit = -> @@ -17,4 +17,11 @@ Darkswarm.controller "LoginCtrl", ($scope, $http, $window, AuthenticationService $http.post("/user/spree_user/confirmation", {spree_user: $scope.spree_user}).success (data)-> $scope.messages = t('devise.confirmations.send_instructions') .error (data) -> - $scope.errors = t('devise.confirmations.failed_to_send') \ No newline at end of file + $scope.errors = t('devise.confirmations.failed_to_send') + + $timeout -> + if angular.isDefined($location.search()['confirmation']) + if $location.search()['confirmation'] == 'confirmed' + $scope.messages = t('devise.confirmations.confirmed') + if $location.search()['confirmation'] == 'not_confirmed' + $scope.errors = t('devise.confirmations.not_confirmed') diff --git a/app/controllers/user_confirmations_controller.rb b/app/controllers/user_confirmations_controller.rb index 7c31abf66b..ffcf315b3e 100644 --- a/app/controllers/user_confirmations_controller.rb +++ b/app/controllers/user_confirmations_controller.rb @@ -25,20 +25,20 @@ class UserConfirmationsController < DeviseController def show self.resource = resource_class.confirm_by_token(params[:confirmation_token]) - if is_navigational_format? - if resource.errors.empty? - set_flash_message(:success, :confirmed) - else - set_flash_message(:error, :not_confirmed) - end - end - respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource) } end protected - def after_confirmation_path_for(resource) - session[:confirmation_return_url] || login_path + def after_confirmation_path_for(_resource) + result = + if resource.errors.empty? + 'confirmed' + else + 'not_confirmed' + end + + url = session[:confirmation_return_url] || login_path + url + "?confirmation=#{result}" end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 898bb0584c..04e075cc82 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -99,6 +99,8 @@ en: send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." failed_to_send: "An error occurred whilst sending your confirmation email." resend_confirmation_email: "Resend confirmation email." + confirmed: "Thanks for confirming your email! You can now sign in." + not_confirmed: "Your email address could not be confirmed. Perhaps you have already completed this step?" user_registrations: spree_user: signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." @@ -107,12 +109,6 @@ en: Invalid email or password. Were you a guest last time? Perhaps you need to create an account or reset your password. unconfirmed: "You have to confirm your account before continuing." - enterprise_confirmations: - enterprise: - confirmed: Thank you, your email address has been confirmed. - not_confirmed: Your email address could not be confirmed. Perhaps you have already completed this step? - confirmation_sent: "Confirmation email sent!" - confirmation_not_sent: "Could not send a confirmation email." enterprise_mailer: confirmation_instructions: subject: "Please confirm the email address for %{enterprise}"