mirror of https://github.com/tootsuite/mastodon
Extract `User::Approval` concern
parent
7e9e390447
commit
6556b26ab0
|
@ -11,4 +11,14 @@ module User::Approval
|
|||
def pending?
|
||||
!approved?
|
||||
end
|
||||
|
||||
def approve!
|
||||
return if approved?
|
||||
|
||||
update!(approved: true)
|
||||
|
||||
# Handle scenario when approving and confirming a user at the same time
|
||||
reload unless confirmed?
|
||||
prepare_new_user! if confirmed?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -242,17 +242,6 @@ class User < ApplicationRecord
|
|||
unconfirmed? || pending?
|
||||
end
|
||||
|
||||
def approve!
|
||||
return if approved?
|
||||
|
||||
update!(approved: true)
|
||||
|
||||
# Avoid extremely unlikely race condition when approving and confirming
|
||||
# the user at the same time
|
||||
reload unless confirmed?
|
||||
prepare_new_user! if confirmed?
|
||||
end
|
||||
|
||||
def otp_enabled?
|
||||
otp_required_for_login
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue