FEAT: Auth useing encrypted credentials in DB
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.mallardromain.hotel.config;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
import com.mallardromain.hotel.model.User;
|
||||
import com.mallardromain.hotel.repository.UserRepository;
|
||||
|
||||
import io.jsonwebtoken.security.Password;
|
||||
|
||||
@Configuration
|
||||
public class DatabaseSeeder {
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner seedDatabase(UserRepository userRepository, PasswordEncoder passwordEncoder) {
|
||||
return args -> {
|
||||
if (userRepository.count() == 0) {
|
||||
User testUser1 = new User("test1", passwordEncoder.encode("password1"));
|
||||
User testUser2 = new User("test2", passwordEncoder.encode("password2"));
|
||||
|
||||
userRepository.save(testUser1);
|
||||
userRepository.save(testUser2);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user