use of com.zavada.repository.UserRepository in project Logos_Materials_October_2017 by VolodymyrZavada.
the class SpringBootConsulttionTestProjectApplication method addAdmin.
static void addAdmin(ConfigurableApplicationContext context) {
String adminEmail = "admin@gmail.com";
String adminPassword = "123";
UserRepository userRepository = context.getBean(UserRepository.class);
UserEntity entity = userRepository.findUserByEmail(adminEmail);
if (entity == null) {
PasswordEncoder encoder = context.getBean(PasswordEncoder.class);
entity = new UserEntity();
entity.setEmail(adminEmail);
entity.setPassword(encoder.encode(adminPassword));
entity.setRole(Role.ROLE_ADMIN);
userRepository.save(entity);
}
}
use of com.zavada.repository.UserRepository in project Logos_Materials_October_2017 by VolodymyrZavada.
the class SpringBootConsultationProjectApplication method addAdmin.
static void addAdmin(ConfigurableApplicationContext context) {
String adminEmail = "admin@gmail.com";
String adminPassword = "123";
UserRepository userRepository = context.getBean(UserRepository.class);
UserEntity entity = userRepository.findUserByEmail(adminEmail);
if (entity == null) {
PasswordEncoder encoder = context.getBean(PasswordEncoder.class);
entity = new UserEntity();
entity.setEmail(adminEmail);
entity.setPassword(encoder.encode(adminPassword));
entity.setRole(Role.ROLE_ADMIN);
userRepository.save(entity);
}
}
Aggregations