mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:42:55 +08:00
FIX: Don't create two reviewable scores for a user
This commit is contained in:
parent
c1ea63bdc1
commit
82bddcbe51
|
@ -5,7 +5,7 @@ class Jobs::CreateUserReviewable < Jobs::Base
|
|||
if user = User.find_by(id: args[:user_id])
|
||||
return if user.approved?
|
||||
|
||||
reviewable = ReviewableUser.needs_review!(target: user, created_by: Discourse.system_user, reviewable_by_moderator: true)
|
||||
reviewable = ReviewableUser.create!(target: user, created_by: Discourse.system_user, reviewable_by_moderator: true)
|
||||
reviewable.add_score(
|
||||
Discourse.system_user,
|
||||
ReviewableScore.types[:needs_approval],
|
||||
|
|
|
@ -57,7 +57,7 @@ class EmailToken < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.confirm(token)
|
||||
def self.confirm(token, skip_reviewable: false)
|
||||
User.transaction do
|
||||
result = atomic_confirm(token)
|
||||
user = result[:user]
|
||||
|
@ -65,8 +65,9 @@ class EmailToken < ActiveRecord::Base
|
|||
# If we are activating the user, send the welcome message
|
||||
user.send_welcome_message = !user.active?
|
||||
user.email = result[:email_token].email
|
||||
user.active = true
|
||||
user.save!
|
||||
user.activate
|
||||
user.create_reviewable unless skip_reviewable
|
||||
user.set_automatic_groups
|
||||
end
|
||||
|
||||
|
|
|
@ -892,7 +892,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
def activate
|
||||
if email_token = self.email_tokens.active.where(email: self.email).first
|
||||
user = EmailToken.confirm(email_token.token)
|
||||
user = EmailToken.confirm(email_token.token, skip_reviewable: true)
|
||||
self.update!(active: true) if user.nil?
|
||||
else
|
||||
self.update!(active: true)
|
||||
|
|
Loading…
Reference in New Issue
Block a user