Commit 9dc39721 by Jan Hrabal

fix

parent e3e3232c
-- default admin user
insert into APP_ROLE (ID, NAME) values (1, 'ADMIN');
insert into APP_ROLE (ID, NAME) values (2, 'MANAGER');
insert into APP_ROLE (ID, NAME) values (3, 'CONTRACTOR');
insert into APP_ROLE (ID, NAME) values (4, 'CONTRACTOR_ADMIN');
insert into APP_USER (ID, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD, PASSWORD_SALT, LOCALE, TIMEZONE_ID) VAlUES (1, 'janhrabal@seznam.cz', 'Jan', 'Hrabal', 'NKz1rz7kSEBXFGbolvEhdomvcDQYmD0IKGADVpuoxL1ztsE1NAnOMvbiSkvc3vwLQvBdPHw449XzgRderNJc9MMnnMTEgJdl3S6dtBGiEYDRHK19toXdwttfaDrXewjyZBJkzy7CxE/BOad4XkiTreIFAUGRedK9TGZ+RWbrJ2KIRrkSX3H1J2eT7HLF8bblkxz2qhjsF5s0k37e3sFI0xAdyCy6qAYS4/MW4WYQ3o0YyZc4krGE2k3y9kfPxWEh/favQKoFIX92ZkRh6ZIXNF7i4oUBl1pcg6r5ykCT83IAWm9avM768NEitEVOx0V8P0PQ2WxGA3n7nicKmwYjow==', 'GACR2Rea1kIhZAlImqK8HauZwTah5eMyKiTzr9HDriryN92YkE5UkWe3Gn7oRLkKEftaNfEfa2Ujj18Rrsed2a6QN69UZCkpRHnwgoBp5ckOOaC6s4undHSjYZW5rJx8CuKXTJpO1TS1LlsjwCyir8oA2gGm480jgGwOefm+r2s=', 'en', 'UTC');
insert into APP_USER_ROLE (USER_ID, ROLE_ID) values (1, 1);
......
......@@ -81,6 +81,12 @@ CREATE TABLE APP_USER (
TIMEZONE_ID VARCHAR(50),
LOCALE VARCHAR(50),
ACCOUNT_ENABLED BOOLEAN DEFAULT TRUE,
ACCOUNT_EXPIRED BOOLEAN DEFAULT FALSE,
ACCOUNT_LOCKED BOOLEAN DEFAULT FALSE,
PASSWORD_EXPIRED BOOLEAN DEFAULT FALSE,
PASSWORD_CHANGED TIMESTAMP,
CONSTRAINT PK_APP_USER PRIMARY KEY(ID)
);
CREATE INDEX APP_USER_EMAIL_IDX ON APP_USER(lower(EMAIL));
......
......@@ -4,6 +4,7 @@
*/
package com.jh.boot.security.model;
import java.util.Date;
import java.util.Set;
import javax.persistence.Column;
......@@ -72,6 +73,21 @@ public class AppUser extends AbstractIdEntity {
@Column(name = "TIMEZONE_ID")
private String timezone;
@Column(name = "ACCOUNT_ENABLED")
private boolean accountEnabled;
@Column(name = "ACCOUNT_EXPIRED")
private boolean accountExpired;
@Column(name = "ACCOUNT_LOCKED")
private boolean accountLocked;
@Column(name = "PASSWORD_EXPIRED")
private boolean passwordExpired;
@Column(name = "PASSWORD_CHANGED")
private Date passwordChanged;
/**
* Gets the email.
*
......@@ -222,4 +238,44 @@ public class AppUser extends AbstractIdEntity {
this.timezone = timezone;
}
public boolean isAccountEnabled() {
return accountEnabled;
}
public void setAccountEnabled(boolean accountEnabled) {
this.accountEnabled = accountEnabled;
}
public boolean isAccountExpired() {
return accountExpired;
}
public void setAccountExpired(boolean accountExpired) {
this.accountExpired = accountExpired;
}
public boolean isAccountLocked() {
return accountLocked;
}
public void setAccountLocked(boolean accountLocked) {
this.accountLocked = accountLocked;
}
public boolean isPasswordExpired() {
return passwordExpired;
}
public void setPasswordExpired(boolean passwordExpired) {
this.passwordExpired = passwordExpired;
}
public Date getPasswordChanged() {
return passwordChanged;
}
public void setPasswordChanged(Date passwordChanged) {
this.passwordChanged = passwordChanged;
}
}
package com.jh.boot.security.repository;
import java.util.Date;
import javax.persistence.Query;
import org.springframework.util.StringUtils;
......@@ -46,6 +48,11 @@ public class AppUserRepository extends AbstractHibernateRepository {
user.setPassword(hash.getHash());
user.setPasswordSalt(hash.getSalt());
user.setAccountEnabled(true);
user.setAccountExpired(false);
user.setPasswordChanged(new Date());
user.setPasswordExpired(false);
entityManager.persist(user);
return user;
......
......@@ -115,6 +115,9 @@ public class AppUserAuthService implements AuthService {
PasswordHash hash = PasswordUtils.hashPassword(newPassword);
user.setPassword(hash.getHash());
user.setPasswordSalt(hash.getSalt());
user.setPasswordChanged(new Date());
user.setPasswordExpired(false);
}
......@@ -130,6 +133,7 @@ public class AppUserAuthService implements AuthService {
}
user.setDeleted(true);
user.setAccountEnabled(false);
}
......
......@@ -7,8 +7,6 @@ package com.jh.boot.web.list;
import java.util.Collections;
import java.util.List;
import com.jh.tsk.model.Contractor;
/**
* TODO.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment