Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/stable' into pkgr
  • Loading branch information
crohr committed Dec 14, 2017
2 parents 9991494 + 5748ad6 commit 2fd2a17
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/users_controller.rb
Expand Up @@ -292,6 +292,8 @@ def user_from_params_or_current_user
params[:for_user_id] ? User.find(params[:for_user_id]) : current_user
end

FROM_STAGED = "from_staged"

def create
params.permit(:user_fields)

Expand All @@ -314,6 +316,8 @@ def create
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
user.active = false
user.custom_fields[FROM_STAGED] = true
else
user = User.new(user_params)
end
Expand Down Expand Up @@ -608,6 +612,7 @@ def update_activation_email
raise Discourse::InvalidAccess.new unless @user.present?
raise Discourse::InvalidAccess.new if @user.active?
raise Discourse::InvalidAccess.new if current_user.present?
raise Discourse::InvalidAccess.new if @user.custom_fields[FROM_STAGED]

User.transaction do
@user.email = params[:email]
Expand Down

0 comments on commit 2fd2a17

Please sign in to comment.