Merge branch 'main' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2023-01-24 20:32:31 +01:00
108 changed files with 1004 additions and 571 deletions

View File

@ -195,10 +195,16 @@ class User < ApplicationRecord
super
if new_user && approved?
prepare_new_user!
elsif new_user
notify_staff_about_pending_account!
if new_user
# Avoid extremely unlikely race condition when approving and confirming
# the user at the same time
reload unless approved?
if approved?
prepare_new_user!
else
notify_staff_about_pending_account!
end
end
end
@ -209,7 +215,13 @@ class User < ApplicationRecord
skip_confirmation!
save!
prepare_new_user! if new_user && approved?
if new_user
# Avoid extremely unlikely race condition when approving and confirming
# the user at the same time
reload unless approved?
prepare_new_user! if approved?
end
end
def update_sign_in!(new_sign_in: false)
@ -261,7 +273,11 @@ class User < ApplicationRecord
return if approved?
update!(approved: true)
prepare_new_user!
# 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?