diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index ab7aa34ff..ddfa2d4c1 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -204,7 +204,7 @@ Discourse.AdminUser = Discourse.User.extend({ }, sendActivationEmail: function() { - Discourse.ajax('/users/' + this.get('username') + '/send_activation_email').then(function() { + Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'}).then(function() { // succeeded bootbox.alert( Em.String.i18n('admin.user.activation_email_sent') ); }, function(e) { diff --git a/app/assets/javascripts/discourse/controllers/not_activated_controller.js b/app/assets/javascripts/discourse/controllers/not_activated_controller.js index e1458697f..5b529bd3d 100644 --- a/app/assets/javascripts/discourse/controllers/not_activated_controller.js +++ b/app/assets/javascripts/discourse/controllers/not_activated_controller.js @@ -11,7 +11,7 @@ Discourse.NotActivatedController = Discourse.Controller.extend(Discourse.ModalFu emailSent: false, sendActivationEmail: function() { - Discourse.ajax('/users/' + this.get('username') + '/send_activation_email'); + Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'}); this.set('emailSent', true); } diff --git a/config/routes.rb b/config/routes.rb index 7cb1d650f..4679da32c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -128,7 +128,7 @@ Discourse::Application.routes.draw do put 'users/:username/preferences/username' => 'users#username', constraints: {username: USERNAME_ROUTE_FORMAT} get 'users/:username/avatar(/:size)' => 'users#avatar', constraints: {username: USERNAME_ROUTE_FORMAT} get 'users/:username/invited' => 'users#invited', constraints: {username: USERNAME_ROUTE_FORMAT} - get 'users/:username/send_activation_email' => 'users#send_activation_email', constraints: {username: USERNAME_ROUTE_FORMAT} + post 'users/:username/send_activation_email' => 'users#send_activation_email', constraints: {username: USERNAME_ROUTE_FORMAT} resources :uploads diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 0587cef32..a44ffef20 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -887,7 +887,7 @@ describe UsersController do context 'with a valid email_token' do it 'should send the activation email' do Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup)) - xhr :get, :send_activation_email, username: user.username + xhr :post, :send_activation_email, username: user.username end end @@ -899,13 +899,13 @@ describe UsersController do it 'should generate a new token' do expect { - xhr :get, :send_activation_email, username: user.username + xhr :post, :send_activation_email, username: user.username }.to change{ user.email_tokens(true).count }.by(1) end it 'should send an email' do Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup)) - xhr :get, :send_activation_email, username: user.username + xhr :post, :send_activation_email, username: user.username end end end @@ -913,7 +913,7 @@ describe UsersController do context 'when username does not exist' do it 'should not send an email' do Jobs.expects(:enqueue).never - xhr :get, :send_activation_email, username: 'nopenopenopenope' + xhr :post, :send_activation_email, username: 'nopenopenopenope' end end end