mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FEATURE: can take over a staged account
This commit is contained in:
parent
a682ec9444
commit
43614439e6
2 changed files with 17 additions and 1 deletions
|
@ -259,7 +259,12 @@ class UsersController < ApplicationController
|
|||
return fail_with("login.reserved_username")
|
||||
end
|
||||
|
||||
user = User.new(user_params)
|
||||
if user = User.where(staged: true).find_by(email: params[:email].strip.downcase)
|
||||
user_params.each { |k, v| user.send("#{k}=", v) }
|
||||
user.staged = false
|
||||
else
|
||||
user = User.new(user_params)
|
||||
end
|
||||
|
||||
# Handle custom fields
|
||||
user_fields = UserField.all
|
||||
|
|
|
@ -746,6 +746,17 @@ describe UsersController do
|
|||
end
|
||||
end
|
||||
|
||||
context "when taking over a staged account" do
|
||||
let!(:staged) { Fabricate(:staged, email: "staged@account.com") }
|
||||
|
||||
it "succeeds" do
|
||||
xhr :post, :create, email: staged.email, username: "zogstrip", password: "P4ssw0rd"
|
||||
result = ::JSON.parse(response.body)
|
||||
expect(result["success"]).to eq(true)
|
||||
expect(User.find_by(email: staged.email).staged).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context '.username' do
|
||||
|
|
Loading…
Reference in a new issue