working on user settings
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -62,6 +62,8 @@ public class FileStore implements ClientService, SessionService, UserService {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<User> list() {
|
||||
return List.of();
|
||||
@@ -98,6 +100,11 @@ public class FileStore implements ClientService, SessionService, UserService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passwordMatches(String password, String hashedPassword) {
|
||||
return passwordHasher.matches(password,hashedPassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStore save(User user) {
|
||||
JSONObject users;
|
||||
@@ -110,6 +117,14 @@ public class FileStore implements ClientService, SessionService, UserService {
|
||||
return save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStore updatePassword(User user, String plaintextPassword) {
|
||||
var oldHashedPassword = user.hashedPassword();
|
||||
var salt = passwordHasher.salt(oldHashedPassword);
|
||||
user.hashedPassword(passwordHasher.hash(plaintextPassword,salt));
|
||||
return save(user);
|
||||
}
|
||||
|
||||
private Optional<User> userOf(JSONObject json, String userId){
|
||||
var user = new User(json.getString(USERNAME), json.getString(PASSWORD), json.getString(REALNAME), json.getString(EMAIL), userId);
|
||||
var perms = json.getJSONArray(PERMISSIONS);
|
||||
@@ -132,7 +147,7 @@ public class FileStore implements ClientService, SessionService, UserService {
|
||||
public Session createSession(User user) {
|
||||
var now = Instant.now();
|
||||
var endOfSession = now.plus(sessionDuration);
|
||||
return save(new Session(user, endOfSession, UUID.randomUUID().toString()));
|
||||
return save(new Session(user, endOfSession, java.util.UUID.randomUUID().toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user