public Profile profileForCurrentUser() { final AuthenticatedUser authenticatedUser = (AuthenticatedUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); final Result<User, UserFailure> result = userService.getUserWith(authenticatedUser.userName); return new Profile(result.success()); }
public Optional<Profile> profileFor(final String username) { final Result<User, UserFailure> result = userService.getUserWith(username); return result.isSuccess() ? Optional.of(new Profile(result.success())) : Optional.empty(); }