mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 05:53:52 +08:00
Ability to skip email validation via a plugin
This commit is contained in:
@ -73,7 +73,7 @@ class User < ActiveRecord::Base
|
||||
validates_presence_of :username
|
||||
validate :username_validator, if: :username_changed?
|
||||
validates :email, presence: true, uniqueness: true
|
||||
validates :email, email: true, if: Proc.new { |u| !u.staged && u.email_changed? }
|
||||
validates :email, email: true, if: :should_validate_email?
|
||||
validate :password_validator
|
||||
validates :name, user_full_name: true, if: :name_changed?
|
||||
validates :ip_address, allowed_ip_address: {on: :create, message: :signup_not_allowed}
|
||||
@ -102,6 +102,9 @@ class User < ActiveRecord::Base
|
||||
TopicViewItem.delete_all(user_id: self.id)
|
||||
end
|
||||
|
||||
# Skip validating email, for example from a particular auth provider plugin
|
||||
attr_accessor :skip_email_validation
|
||||
|
||||
# Whether we need to be sending a system message after creation
|
||||
attr_accessor :send_welcome_message
|
||||
|
||||
@ -247,6 +250,10 @@ class User < ActiveRecord::Base
|
||||
used_invite.try(:invited_by)
|
||||
end
|
||||
|
||||
def should_validate_email?
|
||||
return !skip_email_validation && !staged? && email_changed?
|
||||
end
|
||||
|
||||
# Approve this user
|
||||
def approve(approved_by, send_mail=true)
|
||||
self.approved = true
|
||||
|
Reference in New Issue
Block a user