change status bool to short and remove active_mail

This commit is contained in:
Valentin CZERYBA 2022-08-04 23:14:21 +02:00
parent ea34ae37c0
commit 55da7253db
5 changed files with 20 additions and 71 deletions

View File

@ -1,59 +1,12 @@
# covas-quarkus Project
# Backend COVAS
This project uses Quarkus, the Supersonic Subatomic Java Framework.
C'est la partie backend du projet COVAS généré par le générateur fourni par le framework QUARKUS (Projet semblable à Spring boot de RedHat)
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
## Statut de l'utilisateur
## Running the application in dev mode
You can run your application in dev mode that enables live coding using:
```shell script
./mvnw compile quarkus:dev
```
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
## Packaging and running the application
The application can be packaged using:
```shell script
./mvnw package
```
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
Be aware that its not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
If you want to build an _über-jar_, execute the following command:
```shell script
./mvnw package -Dquarkus.package.type=uber-jar
```
The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
## Creating a native executable
You can create a native executable using:
```shell script
./mvnw package -Pnative
```
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
./mvnw package -Pnative -Dquarkus.native.container-build=true
```
You can then execute your native executable with: `./target/covas-quarkus-1.0-runner`
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
## Related Guides
-1 : suppression
0 : desactivé
1 : activé
2 : en attente de confirmation
## Provided Code
### RESTEasy JAX-RS
Easily start your RESTful Web Services
[Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources)

View File

@ -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();

View File

@ -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()){

View File

@ -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

View File

@ -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()) {