Open HoodLegend opened 3 years ago
@Override public User save(UserRegistrationDto registrationDto) { User user = new User(registrationDto.getFirstName(), registrationDto.getLastName(), registrationDto.getEmail(), passwordEncoder.encode(registrationDto.getPassword()), Arrays.asList(new Role("ROLE_USER")));
return userRepository.save(user);
}
//try like this
This error is because internally, spring will automatically add the prefix ROLE_ to the USER role defined so since it's been specified already, it'll throw an error. So remove that prefix from the passed role.
@Override public User save(UserRegistrationDto registrationDto) { User user = new User(registrationDto.getFirstName(), registrationDto.getPassword(), Arrays.asList(new Role("ROLE_USER"))); return userRepository.save(user); }