убрал ограничения объекта для вашего проекта

master
Anton Romanov 7 months ago
parent 928e7a1e30
commit 18827a9028

@ -51,6 +51,16 @@ public class UserDto {
roles = new LinkedHashSet<>();
}
public UserDto(String login, String password) {
this();
this.login = login;
this.password = password;
this.passwordConfirm = password;
this.email = "email@email.ru";
this.firstName = "user";
this.lastName = "user";
}
public UserDto(User user) {
this();
this.id = user.getId();

@ -82,11 +82,14 @@ public class UserService implements UserDetailsService {
throw new UserPasswordsNotValidOrNotMatchException();
}
User user = userMapper.userDtoToUserEntity(userDto);
user.setActivated(false);
user.setActivationKey(UserUtils.generateActivationKey());
user.setRoles(Collections.singleton(new UserRole(UserRoleConstants.USER)));
user.setActivated(true);
user.setPassword(passwordEncoder.encode(userDto.getPassword()));
user = userRepository.save(user);
//user.setActivationKey(UserUtils.generateActivationKey());
Set<UserRole> set = new HashSet<>();
set.add(new UserRole(UserRoleConstants.USER));
user.setRoles(set);
user = userRepository.save(user);
//TODO: mailService.sendActivationEmail(user);
log.debug("Created Information for User: {}", user.getLogin());
return userMapper.userEntityToUserDto(user);
@ -259,4 +262,9 @@ public class UserService implements UserDetailsService {
.map(role -> new SimpleGrantedAuthority(role.getName()))
.collect(Collectors.toList()));
}
public void createDefaultRoles() {
userRoleRepository.save(new UserRole(UserRoleConstants.USER));
userRoleRepository.save(new UserRole(UserRoleConstants.ADMIN));
}
}

Loading…
Cancel
Save