doortts doortts 2017-04-16
social-login: Add fallback with ignore cases email search
@90dc6239790600e2297062d164f06fb6c86da766
app/models/User.java
--- app/models/User.java
+++ app/models/User.java
@@ -320,6 +320,11 @@
             return subEmail.user;
         }
 
+        User fallback = find.where().ieq("email", email).findUnique();
+        if (fallback != null) {
+            return fallback;
+        }
+
         User anonymous = new NullUser();
         anonymous.email = email;
         return anonymous;
app/service/YonaUserServicePlugin.java
--- app/service/YonaUserServicePlugin.java
+++ app/service/YonaUserServicePlugin.java
@@ -66,7 +66,7 @@
 		User localUser = User.findByEmail(authUser.getEmail()); //find with oAuth email address
 		if(localUser.isAnonymous()){
 			localUser = User.findByEmail(u.email);  // 1st trial: same email address with local user credential
-			if(localUser == null) localUser =  User.find.byId(u.user.id); // 2nd trial: linked user
+			if(localUser == null || localUser.isAnonymous()) localUser =  User.find.byId(u.user.id); // 2nd trial: linked user
 			if(localUser == null) localUser = User.anonymous;
 		}
 
Add a comment
List