mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: Allow sending invites to staged users
This commit is contained in:
@ -218,6 +218,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
EMAIL = %r{([^@]+)@([^\.]+)}
|
||||
FROM_STAGED = "from_staged".freeze
|
||||
|
||||
def self.new_from_params(params)
|
||||
user = User.new
|
||||
@ -228,6 +229,16 @@ class User < ActiveRecord::Base
|
||||
user
|
||||
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
|
||||
end
|
||||
user
|
||||
end
|
||||
|
||||
def self.suggest_name(email)
|
||||
return "" if email.blank?
|
||||
email[/\A[^@]+/].tr(".", " ").titleize
|
||||
@ -987,6 +998,10 @@ class User < ActiveRecord::Base
|
||||
self.user_stat&.time_read
|
||||
end
|
||||
|
||||
def from_staged?
|
||||
custom_fields[User::FROM_STAGED]
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def badge_grant
|
||||
|
Reference in New Issue
Block a user