I have a project generated with Jhipster(Spring Boot) and I have an existing database with a table "Utilisateur" and this one contains already "username" and "password" and other fields.. I would like to use authenticate function of JHipster so that the existing users (in table Utilisateur) can access to thier accounts but I don't know how to do it since authenticate function works with User class that also has "username" and "password" fields.. I searched here https://www.jhipster.tech/user-entity/ but doing it with inheritance (Utilisateur extends User) implies to add User fields to Utilisateur table and I don't have to add new columns to Utilisateur table. Please any simple solution to solve this problem
1 Answer
Just modify manually the generated code: change the name of table in User
class and change the Liquibase migration of User table in src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml
.
As you already have a Utilisateur
table, I would modify Liquibase migration to replace User
table by Utilisateur
table. I would not rename the mapped entity as Utilisateur
, I would keep it named as User
so that I don't have to change all code dealing with authentication.
You should also change test data in users.csv so that it matches the structure of your Utilisateur table.
-
Thanks for the answer! Please, can I keep Utilisateur entity that uses the Table Utilisateur (this table is already present in Liquibase) because it has ManyToOne relationship with other entities ? Mar 11 at 20:53
-
-
I tried to make modifications but I got errors.. Could you please take a look at my code if I really did what you suggest here is my repo github.com/hamaarouf/userAuth (changes on user branch) Mar 11 at 23:59
-
You don't say which errors you got and you're asking for help, are you serious? One thing I can say is that you forgot to modify users.csv Mar 12 at 0:30