Merge pull request #5263 from tgxworld/improve_pattern
REFACTOR: Always validate email by default.
This commit is contained in:
commit
f1615c2148
|
@ -641,7 +641,7 @@ class UsersController < ApplicationController
|
|||
primary_email = @user.primary_email
|
||||
|
||||
primary_email.email = params[:email]
|
||||
primary_email.should_validate_email = true
|
||||
primary_email.skip_validate_email = false
|
||||
|
||||
if primary_email.save
|
||||
@user.email_tokens.create(email: @user.email)
|
||||
|
|
|
@ -89,7 +89,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
after_initialize :add_trust_level
|
||||
|
||||
before_validation :set_should_validate_email
|
||||
before_validation :set_skip_validate_email
|
||||
|
||||
after_create :create_email_token
|
||||
after_create :create_user_stat
|
||||
|
@ -1097,9 +1097,9 @@ class User < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
def set_should_validate_email
|
||||
def set_skip_validate_email
|
||||
if self.primary_email
|
||||
self.primary_email.should_validate_email = should_validate_email_address?
|
||||
self.primary_email.skip_validate_email = !should_validate_email_address?
|
||||
end
|
||||
|
||||
true
|
||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'email_validator'
|
|||
class UserEmail < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
attr_accessor :should_validate_email
|
||||
attr_accessor :skip_validate_email
|
||||
|
||||
before_validation :strip_downcase_email
|
||||
|
||||
|
@ -24,7 +24,7 @@ class UserEmail < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def validate_email?
|
||||
return false unless self.should_validate_email
|
||||
return false if self.skip_validate_email
|
||||
email_changed?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,7 +67,7 @@ describe User do
|
|||
end
|
||||
|
||||
it "doesn't enqueue the system message when the site settings disable it" do
|
||||
SiteSetting.expects(:send_welcome_message?).returns(false)
|
||||
SiteSetting.send_welcome_message = false
|
||||
Jobs.expects(:enqueue).with(:send_system_message, user_id: user.id, message_type: 'welcome_user').never
|
||||
user.enqueue_welcome_message('welcome_user')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue