mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Apply 'hide email account' for invites
This commit is contained in:
committed by
Loïc Guitaut
parent
f31301b6de
commit
73de203843
@@ -49,20 +49,20 @@ class Invite < ActiveRecord::Base
|
||||
self.email = Email.downcase(email) unless email.nil?
|
||||
end
|
||||
|
||||
attr_accessor :email_already_exists
|
||||
attribute :email_already_exists
|
||||
|
||||
def self.emailed_status_types
|
||||
@emailed_status_types ||= Enum.new(not_required: 0, pending: 1, bulk_pending: 2, sending: 3, sent: 4)
|
||||
end
|
||||
|
||||
def user_doesnt_already_exist
|
||||
@email_already_exists = false
|
||||
self.email_already_exists = false
|
||||
return if email.blank?
|
||||
user = Invite.find_user_by_email(email)
|
||||
|
||||
if user && user.id != self.invited_users&.first&.user_id
|
||||
@email_already_exists = true
|
||||
errors.add(:base, user_exists_error_msg(email, user.username))
|
||||
self.email_already_exists = true
|
||||
errors.add(:base, user_exists_error_msg(email))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,9 +100,7 @@ class Invite < ActiveRecord::Base
|
||||
|
||||
email = Email.downcase(opts[:email]) if opts[:email].present?
|
||||
|
||||
if user = find_user_by_email(email)
|
||||
raise UserExists.new(new.user_exists_error_msg(email, user.username))
|
||||
end
|
||||
raise UserExists.new(new.user_exists_error_msg(email)) if find_user_by_email(email)
|
||||
|
||||
if email.present?
|
||||
invite = Invite
|
||||
@@ -270,14 +268,8 @@ class Invite < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def user_exists_error_msg(email, username)
|
||||
sanitized_email = CGI.escapeHTML(email)
|
||||
sanitized_username = CGI.escapeHTML(username)
|
||||
|
||||
I18n.t(
|
||||
"invite.user_exists",
|
||||
email: sanitized_email, username: sanitized_username, base_path: Discourse.base_path
|
||||
)
|
||||
def user_exists_error_msg(email)
|
||||
I18n.t("invite.user_exists", email: CGI.escapeHTML(email))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user