fix: handle emty username & email during sync

This commit is contained in:
Hugo Renard 2022-10-19 16:59:27 +02:00
parent bd39b29422
commit 30e1df99cc
Signed by: hougo
GPG key ID: 3A285FD470209C59

View file

@ -182,9 +182,16 @@ public class UserAdapter extends Adapter<UserModel, UserResource> {
@Override @Override
public Boolean tryToMap() { public Boolean tryToMap() {
var sameUsernameUser = session.users().getUserByUsername(realm, username); UserModel sameUsernameUser = null;
var sameEmailUser = session.users().getUserByEmail(realm, email); UserModel sameEmailUser = null;
if ((sameUsernameUser != null && sameEmailUser != null) && sameUsernameUser.getId() != sameEmailUser.getId()) { if (username != null) {
sameUsernameUser = session.users().getUserByUsername(realm, username);
}
if (email != null) {
sameEmailUser = session.users().getUserByEmail(realm, email);
}
if ((sameUsernameUser != null && sameEmailUser != null)
&& (sameUsernameUser.getId() != sameEmailUser.getId())) {
LOGGER.warnf("found 2 possible users for remote user %s %s", username, email); LOGGER.warnf("found 2 possible users for remote user %s %s", username, email);
return false; return false;
} }