FIX: always unstage users when they log in

This commit is contained in:
Régis Hanol
2018-05-13 17:00:02 +02:00
parent be6404d651
commit 2cf6fb7359
5 changed files with 33 additions and 9 deletions

View File

@ -269,15 +269,18 @@ class User < ActiveRecord::Base
user
end
def unstage
self.staged = false
self.custom_fields[FROM_STAGED] = true
self.notifications.destroy_all
DiscourseEvent.trigger(:user_unstaged, self)
end
def self.unstage(params)
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
params.each { |k, v| user.send("#{k}=", v) }
user.staged = false
user.active = false
user.custom_fields[FROM_STAGED] = true
user.notifications.destroy_all
DiscourseEvent.trigger(:user_unstaged, user)
user.unstage
end
user
end