added account status enum
This commit is contained in:
@ -42,7 +42,7 @@ public class AccountControl {
|
||||
|
||||
public List<AccountEntity> getAccounts() {
|
||||
Query query = em.createQuery("SELECT a FROM AccountEntity a WHERE a.status <> :status", AccountEntity.class);
|
||||
query.setParameter("status", "DELETED"); // TODO add status enum
|
||||
query.setParameter("status", AccountStatus.DISABLED.name());
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public class AccountControl {
|
||||
if (account.getUsername().equals(currentUserName)) {
|
||||
throw new AccountException("Cannot delete own account");
|
||||
} else {
|
||||
account.setStatus("DELETED"); // TODO add enum
|
||||
account.setStatus(AccountStatus.DISABLED.name());
|
||||
account.setLastUpdatedBy(currentUserName);
|
||||
account.setLastUpdatedOn(now);
|
||||
em.merge(account);
|
||||
@ -150,7 +150,7 @@ public class AccountControl {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (account.getStatus().equals("LOCKED")) { // TODO add enumType
|
||||
if (account.getStatus().equals(AccountStatus.BLOCKED.name())) {
|
||||
LOGGER.warn("Account " + userName + " is locked, cannot initialize password reset");
|
||||
return false;
|
||||
}
|
||||
@ -244,7 +244,7 @@ public class AccountControl {
|
||||
|
||||
account.setLastLogin(now);
|
||||
account.setFailureCount(0);
|
||||
account.setStatus("OK"); // TODO add statusEnum
|
||||
account.setStatus(AccountStatus.NORMAL.name());
|
||||
|
||||
em.merge(account);
|
||||
}
|
||||
@ -258,7 +258,7 @@ public class AccountControl {
|
||||
if ((account.getFailureCount() >= maxFailedLogins) && (!account.getStatus().equals("LOCKED"))) { // TOD add status enum
|
||||
// max failed logins reached, disabling user
|
||||
LOGGER.info( "Locking account " + account.getUsername() + " due to " + account.getFailureCount() + " failed logins");
|
||||
account.setStatus("LOCKED"); // TODO add enum
|
||||
account.setStatus(AccountStatus.BLOCKED.name());
|
||||
}
|
||||
|
||||
// on a failed login request, disable password reset
|
||||
|
||||
Reference in New Issue
Block a user