mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 21:11:10 +08:00
FIX: ensure staged accounts are always inactive
If for any reason active is stored in the user model, clear it out prior to creating an account
This commit is contained in:
@ -321,6 +321,7 @@ class UsersController < ApplicationController
|
|||||||
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
|
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
|
||||||
user_params.each { |k, v| user.send("#{k}=", v) }
|
user_params.each { |k, v| user.send("#{k}=", v) }
|
||||||
user.staged = false
|
user.staged = false
|
||||||
|
user.active = false
|
||||||
else
|
else
|
||||||
user = User.new(user_params)
|
user = User.new(user_params)
|
||||||
end
|
end
|
||||||
|
@ -1035,7 +1035,7 @@ describe UsersController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when taking over a staged account" do
|
context "when taking over a staged account" do
|
||||||
let!(:staged) { Fabricate(:staged, email: "staged@account.com") }
|
let!(:staged) { Fabricate(:staged, email: "staged@account.com", active: true) }
|
||||||
|
|
||||||
it "succeeds" do
|
it "succeeds" do
|
||||||
post :create, params: {
|
post :create, params: {
|
||||||
@ -1045,9 +1045,10 @@ describe UsersController do
|
|||||||
result = ::JSON.parse(response.body)
|
result = ::JSON.parse(response.body)
|
||||||
expect(result["success"]).to eq(true)
|
expect(result["success"]).to eq(true)
|
||||||
|
|
||||||
active_user = User.find_by_email(staged.email)
|
created_user = User.find_by_email(staged.email)
|
||||||
expect(active_user.staged).to eq(false)
|
expect(created_user.staged).to eq(false)
|
||||||
expect(active_user.registration_ip_address).to be_present
|
expect(created_user.active).to eq(false)
|
||||||
|
expect(created_user.registration_ip_address).to be_present
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user