FIX: allow retry activation of account by username or password

This commit is contained in:
Sam 2014-09-25 17:42:48 +10:00
parent c4fb7dce23
commit 8f8ea735ee
4 changed files with 8 additions and 4 deletions

View File

@ -266,7 +266,7 @@ Discourse.AdminUser = Discourse.User.extend({
},
sendActivationEmail: function() {
Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'}).then(function() {
Discourse.ajax('/users/action/send_activation_email', {data: {username: this.get('username')}, type: 'POST'}).then(function() {
// succeeded
bootbox.alert( I18n.t('admin.user.activation_email_sent') );
}, function(e) {

View File

@ -7,7 +7,7 @@ export default DiscourseController.extend(ModalFunctionality, {
actions: {
sendActivationEmail: function() {
Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'});
Discourse.ajax('/users/action/send_activation_email', {data: {username: this.get('username')}, type: 'POST'});
this.set('emailSent', true);
}
}

View File

@ -325,7 +325,11 @@ class UsersController < ApplicationController
end
def send_activation_email
@user = fetch_user_from_params(include_inactive: true)
RateLimiter.new(nil, "activate-hr-#{request.remote_ip}", 30, 1.hour).performed!
RateLimiter.new(nil, "activate-min-#{request.remote_ip}", 6, 1.minute).performed!
@user = User.find_by_username_or_email(params[:username].to_s)
@email_token = @user.email_tokens.unconfirmed.active.first
enqueue_activation_email if @user
render nothing: true

View File

@ -232,7 +232,7 @@ Discourse::Application.routes.draw do
delete "users/:username/preferences/user_image" => "users#destroy_user_image", constraints: {username: USERNAME_ROUTE_FORMAT}
put "users/:username/preferences/avatar/pick" => "users#pick_avatar", constraints: {username: USERNAME_ROUTE_FORMAT}
get "users/:username/invited" => "users#invited", constraints: {username: USERNAME_ROUTE_FORMAT}
post "users/:username/send_activation_email" => "users#send_activation_email", constraints: {username: USERNAME_ROUTE_FORMAT}
post "users/action/send_activation_email" => "users#send_activation_email"
get "users/:username/activity" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
get "users/:username/activity/:filter" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
get "users/:username/badges" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}