mirror of
https://github.com/Athou/commafeed.git
synced 2026-11-04 03:14:47 +00:00
invalidate existing sessions on password change
This commit is contained in:
@@ -42,6 +42,9 @@ public class User extends AbstractModel {
|
||||
@Column(nullable = false)
|
||||
private boolean disabled;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int sessionVersion;
|
||||
|
||||
@Column private Instant lastLogin;
|
||||
|
||||
@Column private Instant created;
|
||||
|
||||
@@ -155,6 +155,17 @@ public class UserService {
|
||||
userDAO.delete(user);
|
||||
}
|
||||
|
||||
public void changePassword(User user, String password) {
|
||||
user.setPassword(encryptionService.getEncryptedPassword(password, user.getSalt()));
|
||||
userDAO.merge(user);
|
||||
|
||||
invalidateSessions(user);
|
||||
}
|
||||
|
||||
public void invalidateSessions(User user) {
|
||||
user.setSessionVersion(user.getSessionVersion() + 1);
|
||||
}
|
||||
|
||||
public String generateApiKey(User user) {
|
||||
byte[] key =
|
||||
encryptionService.getEncryptedPassword(
|
||||
|
||||
Reference in New Issue
Block a user