From 30e1df99cc184f19c4b06f014b7b66c14bd43cc6 Mon Sep 17 00:00:00 2001 From: Hugo Renard Date: Wed, 19 Oct 2022 16:59:27 +0200 Subject: [PATCH] fix: handle emty username & email during sync --- src/main/java/sh/libre/scim/core/UserAdapter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/sh/libre/scim/core/UserAdapter.java b/src/main/java/sh/libre/scim/core/UserAdapter.java index f511f9a578..c17ef52e79 100644 --- a/src/main/java/sh/libre/scim/core/UserAdapter.java +++ b/src/main/java/sh/libre/scim/core/UserAdapter.java @@ -182,9 +182,16 @@ public class UserAdapter extends Adapter { @Override public Boolean tryToMap() { - var sameUsernameUser = session.users().getUserByUsername(realm, username); - var sameEmailUser = session.users().getUserByEmail(realm, email); - if ((sameUsernameUser != null && sameEmailUser != null) && sameUsernameUser.getId() != sameEmailUser.getId()) { + UserModel sameUsernameUser = null; + UserModel sameEmailUser = null; + 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); return false; }