Dpatrick has submitted this change and it was merged.

Change subject: Delete users who didn't complete setup on upgrade
......................................................................


Delete users who didn't complete setup on upgrade

Users who started the "Enable two-factor" process, but never confirmed
their setup were stored in the database under the previous format.
After Ife5f1bae4ad65b66c5e20017cc43c0576b4aba19, we no longer look at
the is_validated column to see if the user confirmed their 2fa setup,
and instead only store users in the table who have confirmed.

Delete these users from the table when updating the table format.

Bug: T130892
Change-Id: I54a706043b44db50344d138207b472c35d00724e
---
M OATHAuth.hooks.php
1 file changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Dpatrick: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/OATHAuth.hooks.php b/OATHAuth.hooks.php
index 8bbc24d..aca7c1d 100644
--- a/OATHAuth.hooks.php
+++ b/OATHAuth.hooks.php
@@ -209,7 +209,12 @@
                        return true;
                }
 
-               $res = $db->select( 'oathauth_users', array( 'id', 
'scratch_tokens' ), '', __METHOD__ );
+               $res = $db->select(
+                       'oathauth_users',
+                       array( 'id', 'scratch_tokens' ),
+                       array( 'is_validated != 0' ),
+                       __METHOD__
+               );
 
                foreach ( $res as $row ) {
                        $scratchTokens = unserialize( base64_decode( 
$row->scratch_tokens ) );
@@ -223,6 +228,9 @@
                        }
                }
 
+               // Remove rows from the table where user never completed the 
setup process
+               $db->delete( 'oathauth_users', array( 'is_validated' => 0 ), 
__METHOD__ );
+
                return true;
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/281956
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I54a706043b44db50344d138207b472c35d00724e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OATHAuth
Gerrit-Branch: master
Gerrit-Owner: CSteipp <[email protected]>
Gerrit-Reviewer: Dpatrick <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to