change status bool to short and remove active_mail
This commit is contained in:
@@ -37,10 +37,8 @@ public class UsersEntity extends PanacheEntityBase {
|
||||
public String firstName;
|
||||
@Column(nullable = false)
|
||||
public LocalDate birth;
|
||||
@ColumnDefault("false")
|
||||
public Boolean status;
|
||||
@ColumnDefault("false")
|
||||
public Boolean active_mail;
|
||||
@ColumnDefault("0")
|
||||
public Short status;
|
||||
@Column(nullable = false)
|
||||
public String password;
|
||||
@Column(nullable = false)
|
||||
@@ -64,7 +62,7 @@ public class UsersEntity extends PanacheEntityBase {
|
||||
users.name = name;
|
||||
users.firstName = firstName;
|
||||
users.birth = birth;
|
||||
users.status = true;
|
||||
users.status = 2;
|
||||
users.password = Hash.encryptSHA512(password);
|
||||
users.roles = roles;
|
||||
users.created_at = LocalDateTime.now();
|
||||
|
@@ -59,11 +59,11 @@ public class MailRessource {
|
||||
return Response.status(Response.Status.NOT_ACCEPTABLE).build();
|
||||
}
|
||||
redisClient.del(Arrays.asList(id));
|
||||
if(users.active_mail){
|
||||
if(users.status == 1){
|
||||
return Response.status(Response.Status.NOT_MODIFIED).build();
|
||||
}
|
||||
|
||||
users.active_mail = true;
|
||||
users.status = 1;
|
||||
users.persist();
|
||||
|
||||
if(users.isPersistent()){
|
||||
|
@@ -64,7 +64,7 @@ public class TokenRessource {
|
||||
if(!password.equals(users.password)) {
|
||||
return Response.status(Response.Status.NOT_ACCEPTABLE).build();
|
||||
}
|
||||
if(!users.status){
|
||||
if(users.status != 1){
|
||||
return Response.status(Response.Status.FORBIDDEN).build();
|
||||
}
|
||||
// Create a JWT token signed using the 'HS256' algorithm
|
||||
|
@@ -48,7 +48,7 @@ public class UsersRessources {
|
||||
return false;
|
||||
}
|
||||
String name = new String(Base64.decode(userCookie), StandardCharsets.UTF_8);
|
||||
if (!name.equals(users.pseudo) && (!users.status)) {
|
||||
if (!name.equals(users.pseudo) && (users.status != 1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -166,8 +166,7 @@ public class UsersRessources {
|
||||
usersNew.password = Hash
|
||||
.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8)));
|
||||
usersNew.roles = users.roles;
|
||||
usersNew.status = false;
|
||||
usersNew.active_mail = false;
|
||||
usersNew.status = 2;
|
||||
usersNew.persist();
|
||||
if (usersNew.isPersistent()) {
|
||||
status = Response.Status.CREATED;
|
||||
@@ -209,8 +208,7 @@ public class UsersRessources {
|
||||
usersNew.password = Hash
|
||||
.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8)));
|
||||
usersNew.roles = users.roles;
|
||||
usersNew.status = false;
|
||||
usersNew.active_mail = true;
|
||||
usersNew.status = 2;
|
||||
usersNew.persist();
|
||||
if (usersNew.isPersistent()) {
|
||||
status = Response.Status.CREATED;
|
||||
@@ -233,7 +231,7 @@ public class UsersRessources {
|
||||
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||
|
||||
if (status.equals(Response.Status.OK)) {
|
||||
user.status = false;
|
||||
user.status = 0;
|
||||
user.updated_at = LocalDateTime.now();
|
||||
user.deleted_at = LocalDateTime.now();
|
||||
user.persist();
|
||||
@@ -258,7 +256,7 @@ public class UsersRessources {
|
||||
if (singleUser == null) {
|
||||
status = Response.Status.NOT_FOUND;
|
||||
} else {
|
||||
singleUser.status = false;
|
||||
singleUser.status = 0;
|
||||
singleUser.updated_at = LocalDateTime.now();
|
||||
singleUser.deleted_at = LocalDateTime.now();
|
||||
singleUser.persist();
|
||||
@@ -296,9 +294,9 @@ public class UsersRessources {
|
||||
usersOrig.password = Hash
|
||||
.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8)));
|
||||
usersOrig.roles = users.roles;
|
||||
if(users.status){
|
||||
if(users.status == 1){
|
||||
usersOrig.deleted_at = null;
|
||||
usersOrig.status = true;
|
||||
usersOrig.status = 1;
|
||||
}
|
||||
usersOrig.persist();
|
||||
if (!usersOrig.isPersistent()) {
|
||||
|
Reference in New Issue
Block a user