diff --git a/CHANGELOG.md b/CHANGELOG.md index b522361210e61ffa2c0fc90c3da35af652d85868..76e20e39e9aea4cd08be4a38849452398ec5d112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* #120 - Editing entities that were created with a no longer existing user + leads to a server error. * #31 - Queries with keywords in the path (e.g. `... STORED AT 0in.txt`) * #116 - Queries `FIND [ANY VERSION OF] *` and `FIND [ANY VERSION OF] ENTITY`. diff --git a/src/main/java/org/caosdb/server/accessControl/UserSources.java b/src/main/java/org/caosdb/server/accessControl/UserSources.java index 8f69c8c5c86faea903a29049c3a604121b8951ad..a7abd1405f3d566bb672befc86b853dcf2a17357 100644 --- a/src/main/java/org/caosdb/server/accessControl/UserSources.java +++ b/src/main/java/org/caosdb/server/accessControl/UserSources.java @@ -79,8 +79,18 @@ public class UserSources extends HashMap<String, UserSource> { private static UserSources instance = new UserSources(); + /** + * Check whether a user exists. + * + * @param principal - principal of the user. + * @return true iff the user identified by the given {@link Principal} exists. + */ public static boolean isUserExisting(final Principal principal) { - return instance.get(principal.getRealm()).isUserExisting(principal.getUsername()); + UserSource userSource = instance.get(principal.getRealm()); + if (userSource != null) { + return userSource.isUserExisting(principal.getUsername()); + } + return false; } private UserSources() {