From 916cc1365eb5cdd9bd021e26eb13937c02d7cdb8 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 28 Jul 2025 04:52:59 -0400 Subject: [PATCH] Fix `Style/GuardClause` in `User#wrap_email_confirmation` (#35524) --- app/models/user.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 762522f2822..781a3482163 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -466,16 +466,17 @@ class User < ApplicationRecord yield - if new_user - # Avoid extremely unlikely race condition when approving and confirming - # the user at the same time - reload unless approved? + after_confirmation_tasks if new_user + end - if approved? - prepare_new_user! - else - notify_staff_about_pending_account! - end + def after_confirmation_tasks + # Handle condition when approving and confirming a user at the same time + reload unless approved? + + if approved? + prepare_new_user! + else + notify_staff_about_pending_account! end end