February 2019
Intermediate to advanced
442 pages
11h 46m
English
If all validations are satisfied, then we will do user registration along with role mapping with the following code:
val userEntity = User()userEntity.setUsername(userRegistrationDto.username)userEntity.setEnabled(true)val encodedPassword = passwordEncoder?.encode(userRegistrationDto.password)userEntity.setPassword(encodedPassword ?: "")userEntity.setFirstname(userRegistrationDto.firstname)userEntity.setLastname(userRegistrationDto.lastname)var role:Role?=nullvar roles: MutableSet<Role> = mutableSetOf()for(roleName in userRegistrationDto.roleList){ role = roleRepository?.findByRole(roleName) if(role !=null) { roles.add(role) }}userEntity.setRoles(roles)userRepository?.save(userEntity)val msgLst = Arrays.asList("User registered ...