@@ -392,13 +392,14 @@ private static AuthRecipeUserInfo getAuthRecipeUserInfo(Start start, Connection
392392 return userInfo ;
393393 }
394394
395- public static String getPrimaryUserIdUsingEmail (Start start , AppIdentifier appIdentifier , String email )
395+ public static String getPrimaryUserIdUsingEmail (Start start , TenantIdentifier tenantIdentifier , String email )
396396 throws StorageQueryException {
397397 try {
398398 return start .startTransaction (con -> {
399399 try {
400400 Connection sqlConnection = (Connection ) con .getConnection ();
401- return getPrimaryUserIdUsingEmail_Transaction (start , sqlConnection , appIdentifier , email );
401+ return getPrimaryUserIdForTenantUsingEmail_Transaction (start , sqlConnection , tenantIdentifier ,
402+ email );
402403 } catch (SQLException e ) {
403404 throw new StorageQueryException (e );
404405 }
@@ -408,12 +409,37 @@ public static String getPrimaryUserIdUsingEmail(Start start, AppIdentifier appId
408409 }
409410 }
410411
411- public static String getPrimaryUserIdUsingEmail_Transaction (Start start , Connection sqlConnection , AppIdentifier appIdentifier , String email )
412+ public static String getPrimaryUserIdForTenantUsingEmail_Transaction (Start start , Connection sqlConnection ,
413+ TenantIdentifier tenantIdentifier ,
414+ String email )
412415 throws SQLException , StorageQueryException {
413416 String QUERY = "SELECT DISTINCT all_users.primary_or_recipe_user_id AS user_id "
414417 + "FROM " + getConfig (start ).getWebAuthNUserToTenantTable () + " AS webauthn" +
415418 " JOIN " + getConfig (start ).getUsersTable () + " AS all_users" +
416- " ON webauthn.app_id = all_users.app_id AND webauthn.user_id = all_users.user_id" +
419+ " ON webauthn.tenant_id = all_users.tenant_id " +
420+ " AND webauthn.app_id = all_users.app_id" +
421+ " AND webauthn.user_id = all_users.user_id" +
422+ " WHERE webauthn.tenant_id = ? AND webauthn.app_id = ? AND webauthn.email = ?" ;
423+
424+ return execute (sqlConnection , QUERY , pst -> {
425+ pst .setString (1 , tenantIdentifier .getTenantId ());
426+ pst .setString (2 , tenantIdentifier .getAppId ());
427+ pst .setString (3 , email );
428+ }, result -> {
429+ if (result .next ()) {
430+ return result .getString ("user_id" );
431+ }
432+ return null ;
433+ });
434+ }
435+
436+ public static String getPrimaryUserIdForAppUsingEmail_Transaction (Start start , Connection sqlConnection ,
437+ AppIdentifier appIdentifier , String email )
438+ throws SQLException , StorageQueryException {
439+ String QUERY = "SELECT DISTINCT all_users.primary_or_recipe_user_id AS user_id " +
440+ " FROM " + getConfig (start ).getWebAuthNUserToTenantTable () + " AS webauthn" +
441+ " JOIN " + getConfig (start ).getUsersTable () + " AS all_users" +
442+ " ON webauthn.user_id = all_users.user_id" +
417443 " WHERE webauthn.app_id = ? AND webauthn.email = ?" ;
418444
419445 return execute (sqlConnection , QUERY , pst -> {
0 commit comments