changes user verifications for hidden users
This commit is contained in:
@@ -23,8 +23,8 @@ class User < ActiveRecord::Base
|
||||
has_many :comments, -> { with_hidden }
|
||||
has_many :failed_census_calls
|
||||
|
||||
validates :username, presence: true, unless: :organization?
|
||||
validates :username, uniqueness: true, unless: :organization?
|
||||
validates :username, presence: true, if: :username_required?
|
||||
validates :username, uniqueness: true, if: :username_required?
|
||||
validates :document_number, uniqueness: { scope: :document_type }, allow_nil: true
|
||||
|
||||
validate :validate_username_length
|
||||
@@ -147,6 +147,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def erase(erase_reason = nil)
|
||||
self.hide
|
||||
self.update(
|
||||
erase_reason: erase_reason,
|
||||
username: nil,
|
||||
@@ -159,8 +160,6 @@ class User < ActiveRecord::Base
|
||||
reset_password_token: nil,
|
||||
email_verification_token: nil
|
||||
)
|
||||
|
||||
self.hide
|
||||
end
|
||||
|
||||
def email_provided?
|
||||
@@ -189,8 +188,15 @@ class User < ActiveRecord::Base
|
||||
super
|
||||
end
|
||||
|
||||
private
|
||||
def username_required?
|
||||
!organization? && !hidden?
|
||||
end
|
||||
|
||||
def email_required?
|
||||
!hidden?
|
||||
end
|
||||
|
||||
private
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user