You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/05/27 03:03:44 UTC
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1025: JAMES-3756 Webadmin API for delegation
quantranhong1999 commented on code in PR #1025:
URL: https://github.com/apache/james-project/pull/1025#discussion_r883235120
##########
server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java:
##########
@@ -224,6 +255,84 @@ private String verifyUser(Request request, Response response) throws UsersReposi
}
}
+ private List<String> getAuthorizedUsers(Request request, Response response) throws UsersRepositoryException {
+ Username baseUser = extractUsername(request);
+
+ if (userService.userExists(baseUser)) {
+ return Flux.from(delegationStore.authorizedUsers(baseUser))
+ .map(Username::asString)
+ .collectList()
+ .block();
+ } else {
+ throw ErrorResponder.builder()
+ .statusCode(HttpStatus.NOT_FOUND_404)
+ .type(ErrorType.INVALID_ARGUMENT)
+ .message(String.format("User '%s' does not exist", baseUser.asString()))
+ .haltError();
+ }
+ }
+
+ private String clearAllAuthorizedUsers(Request request, Response response) throws UsersRepositoryException {
+ Username baseUser = extractUsername(request);
+
+ if (userService.userExists(baseUser)) {
+ Mono.from(delegationStore.clear(baseUser)).block();
+ return Constants.EMPTY_BODY;
+ } else {
+ throw ErrorResponder.builder()
+ .statusCode(HttpStatus.NOT_FOUND_404)
+ .type(ErrorType.INVALID_ARGUMENT)
+ .message(String.format("User '%s' does not exist", baseUser.asString()))
+ .haltError();
+ }
+ }
+
+ private String addAuthorizedUser(Request request, Response response) throws UsersRepositoryException {
+ Username baseUser = extractUsername(request);
+ Username delegatedUser = extractDelegatedUsername(request);
+
+ if (!userService.userExists(baseUser)) {
+ throw ErrorResponder.builder()
+ .statusCode(HttpStatus.NOT_FOUND_404)
+ .type(ErrorType.INVALID_ARGUMENT)
+ .message(String.format("User '%s' does not exist", baseUser.asString()))
+ .haltError();
+ } else if (!userService.userExists(delegatedUser)) {
+ response.status(HttpStatus.CONFLICT_409);
Review Comment:
rf: https://github.com/linagora/james-project/issues/4546#issue-1236728350
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org