예제 #1
0
  public OperationResult registerNewUser(final RegisterCredentials credentials) {
    notNull(credentials);

    final Result<UserSuccess, UserFailure> result =
        userService.registerUser(
            credentials.getUsername(),
            credentials.getEmail(),
            credentials.getFirstname(),
            credentials.getLastname(),
            credentials.getPassword());
    return result.isSuccess()
        ? success()
        : failure("User already exists"); // TODO [dh] Proper error mapping!
  }
예제 #2
0
 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());
 }
예제 #3
0
 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();
 }