@@ -209,16 +209,25 @@ component {
209209 return result ;
210210 }
211211
212- public array function listMFA (required string email ) {
212+ public any function listMFA (required string email ) {
213213 var token = getAuthToken ();
214- var userId = getUserByEmail (email )[1 ].user_id ;
215-
216- var result = makeRequest (
217- method = " GET" ,
218- endpoint = " /api/v2/users/#userID #/authentication-methods" ,
219- token = token
220- );
221-
214+ var auth0user = getUserByEmail (email )
215+ var result = {};
216+ if (ArrayLen (auth0user ) > 0 ) {
217+ var userId = auth0user [1 ].user_id ;
218+ try {
219+ result = makeRequest (
220+ method = " GET" ,
221+ endpoint = " /api/v2/users/#userID #/authentication-methods" ,
222+ token = token
223+ );
224+ } catch (any e ) {
225+
226+ }
227+ }else {
228+ // If the user does not exist in Auth0
229+ return { " error" : true , " message" : " noUser" };
230+ }
222231 return result ;
223232 }
224233
@@ -435,7 +444,7 @@ component {
435444 );
436445 successCount ++ ;
437446 } catch (any e ) {
438- arrayAppend ( errors , e . message );
447+ application . fc . lib . error . logData ( application . fc . lib . error . normalizeError ( e ) );
439448 }
440449 }
441450 } else {
@@ -775,8 +784,9 @@ component {
775784 INNER JOIN dmProfile p ON concat(u.userID, '_CLIENTUD')=p.username
776785 INNER JOIN farUser_aGroups ug ON u.objectid=ug.parentid AND ug.data=:groupID
777786 WHERE u.userstatus IN ('active','pending') AND
778- p.lastLogin >= DATE_SUB(NOW(), INTERVAL 12 MONTH)
779- ORDER BY u.objectid ASC
787+ p.emailAddress IS NOT NULL AND
788+ p.emailAddress <> ''
789+ ORDER BY p.lastLogin DESC
780790 " , { groupID = arguments .oldGroupID }, { datasource = application .dsn_read , maxRows = arguments .maxRows });
781791 }
782792 else {
@@ -785,8 +795,11 @@ component {
785795 FROM farUser u
786796 INNER JOIN dmProfile p ON concat(u.userID, '_CLIENTUD')=p.username
787797 WHERE u.userstatus IN ('active','pending') AND
788- p.lastLogin >= DATE_SUB(NOW(), INTERVAL 12 MONTH)
789- ORDER BY u.objectid ASC
798+ (u.lGroups IS NULL OR u.lGroups = '') AND
799+ u.userID <> 'root' AND
800+ p.emailAddress IS NOT NULL AND
801+ p.emailAddress <> ''
802+ ORDER BY p.lastLogin DESC
790803 " , { }, { datasource = application .dsn_read , maxRows = arguments .maxRows });
791804 }
792805 }
@@ -893,15 +906,23 @@ component {
893906 public void function runMigration (required string oldGroupName , required query qUsers , boolean sendCompletion ) {
894907 var safeBatchSize = 300 ;
895908 if (qUsers .recordCount <= 20 ) {
909+ try {
896910 processBatch (arguments .qUsers , arguments .oldGroupName , arguments .sendCompletion );
911+ } catch (any e ) {
912+ application .fc .lib .error .logData (application .fc .lib .error .normalizeError (e ));
913+ }
897914 } else {
898915 var totalRows = qUsers .recordCount ;
899916 var currentIndex = 1 ;
900917
901918 while (currentIndex <= totalRows ) {
919+ try {
902920 var endIndex = min (currentIndex + safeBatchSize - 1 , totalRows );
903921 var batchQuery = createBatchQuery (qUsers , currentIndex , endIndex );
904922 processBatch (batchQuery , arguments .oldGroupName , arguments .sendCompletion );
923+ } catch (any e ) {
924+ application .fc .lib .error .logData (application .fc .lib .error .normalizeError (e ));
925+ }
905926 currentIndex + = safeBatchSize ;
906927 }
907928 }
0 commit comments