working on SqliteUserService

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-09-08 09:47:43 +02:00
parent 47910b5460
commit 9124ff570e
4 changed files with 102 additions and 56 deletions

View File

@@ -151,7 +151,6 @@ public class FileStore implements AuthorizationService, ClientService, SessionSe
var result = new HashSet<User>();
for (var id : users.keySet()) {
var data = users.getJSONObject(id);
if (id.equals(key)) User.of(data, id).ifPresent(result::add);
if (KEYS.stream().map(data::getString).anyMatch(val -> val.equals(key))) User.of(data, id).ifPresent(result::add);
}
return result;
@@ -181,13 +180,12 @@ public class FileStore implements AuthorizationService, ClientService, SessionSe
public Optional<User> load(String user, String password) {
try {
var users = json.getJSONObject(USERS);
var uuids = users.keySet();
for (String userId : uuids) {
for (String userId : users.keySet()) {
var userData = users.getJSONObject(userId);
if (KEYS.stream().map(userData::getString).noneMatch(val -> val.equals(user))) continue;
var hashedPass = userData.getString(PASSWORD);
if (passwordHasher.matches(password, hashedPass)) return User.of(userData, userId);
if (passwordMatches(password, hashedPass)) return User.of(userData, userId);
}
return empty();
} catch (Exception e) {