diff --git a/src/main/java/com/covas/ApplicationLifeCycle.java b/src/main/java/com/covas/ApplicationLifeCycle.java index ac04296..ac09d0e 100644 --- a/src/main/java/com/covas/ApplicationLifeCycle.java +++ b/src/main/java/com/covas/ApplicationLifeCycle.java @@ -30,6 +30,9 @@ public class ApplicationLifeCycle { LOGGER.info("The application has started"); if (schemaCreate){ Users users = new Users(); + Users users2 = new Users(); + + if(users.findByPseudo("Peter") == null){ users.pseudo = "Peter"; users.email = "peter@email.com"; @@ -38,10 +41,25 @@ public class ApplicationLifeCycle { users.birth = LocalDate.of(1993, Month.FEBRUARY, 23); users.status = true; users.password = "toto"; + users.roles = Roles.User; users.persist(); - LOGGER.info("Users test was created"); + LOGGER.info("Peter test was created"); } else { - LOGGER.info("User test wasn't created"); + LOGGER.info("Peter's user test wasn't created"); + } + if(users2.findByPseudo("Robert") == null){ + users2.pseudo = "Robert"; + users2.email = "robert@email.com"; + users2.name = "Toto"; + users2.firstName = "Peter"; + users2.birth = LocalDate.of(1993, Month.FEBRUARY, 23); + users2.status = true; + users2.password = "toto"; + users2.roles = Roles.Admin; + users2.persist(); + LOGGER.info("Robert test was created"); + } else { + LOGGER.info("Robert's user test wasn't created"); } } else { LOGGER.info("DB init wassn't created"); diff --git a/src/main/java/com/covas/TokenRessource.java b/src/main/java/com/covas/TokenRessource.java index eee5144..e4142bc 100644 --- a/src/main/java/com/covas/TokenRessource.java +++ b/src/main/java/com/covas/TokenRessource.java @@ -14,7 +14,6 @@ import javax.transaction.Transactional; import javax.ws.rs.CookieParam; import javax.ws.rs.GET; import javax.ws.rs.InternalServerErrorException; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; diff --git a/src/main/java/com/covas/Users.java b/src/main/java/com/covas/Users.java index 14f413e..ab12b47 100644 --- a/src/main/java/com/covas/Users.java +++ b/src/main/java/com/covas/Users.java @@ -9,6 +9,10 @@ import org.hibernate.annotations.ColumnDefault; import io.quarkus.hibernate.orm.panache.PanacheEntity; +enum Roles { + User, + Admin +} @Entity public class Users extends PanacheEntity { @@ -27,6 +31,8 @@ public class Users extends PanacheEntity { public Boolean status; @Column(nullable = false) public String password; + + public Roles roles; public static Users findByPseudo(String pseudo){ return find("pseudo", pseudo).firstResult();