@RequestMapping(value = "/delete", method = RequestMethod.POST) public @ResponseBody Boolean delete(@RequestParam String username) { User existingUser = new User(); existingUser.setUsername(username); return service.delete(existingUser); }
@RequestMapping(value = "/update", method = RequestMethod.POST) public @ResponseBody UserDto update( @RequestParam String username, @RequestParam String firstName, @RequestParam String lastName, @RequestParam Integer role) { Role existingRole = new Role(); existingRole.setRole(role); User existingUser = new User(); existingUser.setUsername(username); existingUser.setFirstName(firstName); existingUser.setLastName(lastName); existingUser.setRole(existingRole); return UserMapper.map(service.update(existingUser)); }
/** * Returns a populated {@link UserDetails} object. The username is first retrieved from the * database and then mapped to a {@link UserDetails} object. */ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { try { org.krams.domain.User domainUser = userRepository.findByUsername(username); boolean enabled = true; boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; return new User( domainUser.getUsername(), domainUser.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(domainUser.getRole().getRole())); } catch (Exception e) { throw new RuntimeException(e); } }
@RequestMapping(value = "/create", method = RequestMethod.POST) public @ResponseBody UserDto create( @RequestParam String username, @RequestParam String password, @RequestParam String firstName, @RequestParam String lastName, @RequestParam Integer role) { Role newRole = new Role(); newRole.setRole(role); User newUser = new User(); newUser.setUsername(username); newUser.setPassword(password); newUser.setFirstName(firstName); newUser.setLastName(lastName); newUser.setRole(newRole); return UserMapper.map(service.create(newUser)); }