Skip to content

Commit

Permalink
[NOISSUE]
Browse files Browse the repository at this point in the history
move scope
  • Loading branch information
jj committed Mar 5, 2019
1 parent 88384a5 commit 0b8bee1
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
if (defaultPassword != null && !"".equals(defaultPassword)) {
// TODO: yeah, this isn't good, but we gotta initialize this user for now
Role adminRole = roleRepository.findByName("ROLE_ADMIN").orElseGet(() -> {
Role r = new Role();
r.setName("ROLE_ADMIN");
return roleRepository.saveAndFlush(r);
});
User adminUser = userRepository.findByUsername("root").orElseGet(() ->{
User u = new User();
u.setUsername("root");
u.setPassword(defaultPassword);
u.setFirstName("admin");
u.setLastName("user");
Role adminRole = roleRepository.findByName("ROLE_ADMIN").orElseGet(() -> {
Role r = new Role();
r.setName("ROLE_ADMIN");
return roleRepository.saveAndFlush(r);
});
u.setRoles(Collections.singleton(adminRole));
u.setEmailAddress("admin@localhost");
return userRepository.saveAndFlush(u);
Expand Down

0 comments on commit 0b8bee1

Please sign in to comment.