diff --git a/lib/src/main/java/com/auth0/android/lock/Configuration.java b/lib/src/main/java/com/auth0/android/lock/Configuration.java index 63eb61e1a..c839ea1ed 100644 --- a/lib/src/main/java/com/auth0/android/lock/Configuration.java +++ b/lib/src/main/java/com/auth0/android/lock/Configuration.java @@ -229,9 +229,11 @@ private List filterSocialStrategies(List strategies, Set filtered = new ArrayList<>(strategies.size()); for (Strategy strategy : strategies) { - final boolean allowed = connections.isEmpty() || connections.contains(strategy.getDefaultConnectionName()); - if (allowed && strategy.getDefaultConnectionName() != null) { - filtered.add(strategy); + for (Connection connection : strategy.getConnections()) { + if (connections.isEmpty() || connections.contains(connection.getName())) { + filtered.add(strategy); + break; + } } } return filtered; diff --git a/lib/src/main/java/com/auth0/android/lock/utils/json/Strategy.java b/lib/src/main/java/com/auth0/android/lock/utils/json/Strategy.java index 435dcd237..bdd3d9734 100644 --- a/lib/src/main/java/com/auth0/android/lock/utils/json/Strategy.java +++ b/lib/src/main/java/com/auth0/android/lock/utils/json/Strategy.java @@ -83,9 +83,6 @@ public boolean isActiveFlowEnabled() { */ @Nullable public String getDefaultConnectionName() { - if (!connections.isEmpty()) { - return connections.get(0).getName(); - } - return null; + return !connections.isEmpty() ? connections.get(0).getName() : null; } } \ No newline at end of file diff --git a/lib/src/test/java/com/auth0/android/lock/ConfigurationTest.java b/lib/src/test/java/com/auth0/android/lock/ConfigurationTest.java index 0329c9421..96de07f8e 100644 --- a/lib/src/test/java/com/auth0/android/lock/ConfigurationTest.java +++ b/lib/src/test/java/com/auth0/android/lock/ConfigurationTest.java @@ -504,6 +504,14 @@ public void shouldReturnEmptyPasswordlessStrategiesIfNoneMatch() throws Exceptio assertThat(strategy, is(nullValue())); } + @Test + public void shouldNotReturnDuplicatedSocialStrategies() throws Exception { + configuration = filteredConfigBy("twitter", "twitter-dev"); + final List strategies = configuration.getSocialStrategies(); + assertThat(strategies, hasItems(isStrategy(Twitter))); + assertThat(strategies, hasSize(1)); + } + @Test public void shouldReturnUnfilteredSocialStrategiesWithConnections() throws Exception { configuration = unfilteredConfig(); diff --git a/lib/src/test/resources/appinfo.json b/lib/src/test/resources/appinfo.json index 0a61dbdd2..239a69a7a 100644 --- a/lib/src/test/resources/appinfo.json +++ b/lib/src/test/resources/appinfo.json @@ -99,6 +99,9 @@ "name": "twitter", "connections": [{ "name": "twitter" + }, + { + "name": "twitter-dev" }] }, { "name": "linkedin",