Reputation: 169
I want change the admin default username and password in my JHipster code. How to set a new one?
Upvotes: 0
Views: 8150
Reputation: 2654
You can change the credentials of any default user by following the steps mentioned below:
src/main/resources/config/liquibase/data/users.csv
Upvotes: 0
Reputation: 119
You can change/initialize your password with following steps:
Open UserServiceIntTest.java generated by JHipster(or any other test annotated with @SpringBootTest in your project), add following to your XXXTest.java
import org.springframework.security.crypto.password.PasswordEncoder;
...
@Autowired
private PasswordEncoder passwordEncoder;
@Test
public void testPasswordEncoder() {
// replace "Abcd1234" with your passord
String hash = passwordEncoder.encode("Abcd1234");
System.out.println(hash);
}
Copy the generated hash to admin entry of src/main/resources/config/liquibase/users.csv
Compile and restart your application, now you can login with your new password.
Upvotes: 2
Reputation: 18963
As @jperis told in comments, the database is seeded with initial data from src/main/resources/config/liquibase/users.csv
(or src/main/resources/config/mongeeze/users.xml
in case of MongoDB), so you need to change the admin username and password there.
However, passwords are stored hashed and salted in the database, so there's no easy way to generate a new valid password record manually.
The workaround is to let JHipster update the passwords as @sdoxsee suggested and extract them from the database:
users.csv
replacing admin password, optionally change admin usernamesystem
user password similarly and remove user
rowUPDATE
See this JHipster password change utility proposal.
Upvotes: 3
Reputation: 4701
What I've usually done is 1) run the generated application, 2) login as admin (with the default password) 3) change the password for the admin user from the 'Password' page
You probably don't want your real admin password in your source code even if isn't plaintext. Using the approach I suggest above, your new password will only be accessible in your database (and it will be non-plaintext)
Upvotes: 5