Skip to content

Commit

Permalink
social-login: Add fallback with ignore cases email search
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Apr 15, 2017
1 parent d071e97 commit 90dc623
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/models/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ public static User findByEmail(String email) {
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;
Expand Down
2 changes: 1 addition & 1 deletion app/service/YonaUserServicePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private boolean setStatusLoggedIn(@Nonnull UserCredential u, BasicIdentity authU
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;
}

Expand Down

0 comments on commit 90dc623

Please sign in to comment.