mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 23:34:26 +08:00
FIX: Resend activation email was busted
This commit is contained in:
parent
6646b23569
commit
e4287d9de9
|
@ -212,11 +212,14 @@ class ApplicationController < ActionController::Base
|
||||||
Middleware::AnonymousCache.anon_cache(request.env, time_length)
|
Middleware::AnonymousCache.anon_cache(request.env, time_length)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_user_from_params
|
def fetch_user_from_params(opts=nil)
|
||||||
|
opts ||= {}
|
||||||
user = if params[:username]
|
user = if params[:username]
|
||||||
username_lower = params[:username].downcase
|
username_lower = params[:username].downcase
|
||||||
username_lower.gsub!(/\.json$/, '')
|
username_lower.gsub!(/\.json$/, '')
|
||||||
User.find_by(username_lower: username_lower, active: true)
|
find_opts = {username_lower: username_lower}
|
||||||
|
find_opts[:active] = true unless opts[:include_inactive]
|
||||||
|
User.find_by(find_opts)
|
||||||
elsif params[:external_id]
|
elsif params[:external_id]
|
||||||
SingleSignOnRecord.find_by(external_id: params[:external_id]).try(:user)
|
SingleSignOnRecord.find_by(external_id: params[:external_id]).try(:user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -312,7 +312,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_activation_email
|
def send_activation_email
|
||||||
@user = fetch_user_from_params
|
@user = fetch_user_from_params(include_inactive: true)
|
||||||
@email_token = @user.email_tokens.unconfirmed.active.first
|
@email_token = @user.email_tokens.unconfirmed.active.first
|
||||||
enqueue_activation_email if @user
|
enqueue_activation_email if @user
|
||||||
render nothing: true
|
render nothing: true
|
||||||
|
|
|
@ -961,11 +961,7 @@ describe UsersController do
|
||||||
|
|
||||||
describe 'send_activation_email' do
|
describe 'send_activation_email' do
|
||||||
context 'for an existing user' do
|
context 'for an existing user' do
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user, active: false) }
|
||||||
|
|
||||||
before do
|
|
||||||
UsersController.any_instance.stubs(:fetch_user_from_params).returns(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with a valid email_token' do
|
context 'with a valid email_token' do
|
||||||
it 'should send the activation email' do
|
it 'should send the activation email' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user