Search in sources :

Example 1 with InvitationActionWithTokenDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionWithTokenDTO in project ArachneCentralAPI by OHDSI.

the class BaseUserController method invitationAcceptViaMail.

@ApiOperation("Accept invitations via mail.")
@RequestMapping(value = "/api/v1/user-management/users/invitations/mail", method = GET)
public JsonResult<UserProfileDTO> invitationAcceptViaMail(@RequestParam("id") Long id, @RequestParam("accepted") Boolean accepted, @RequestParam("type") String type, @RequestParam("token") String token, @RequestParam(value = "userId", required = false) Long userId, HttpServletResponse response) throws NotExistException, AlreadyExistException, IOException {
    InvitationActionWithTokenDTO dto = new InvitationActionWithTokenDTO(id, type, accepted, token);
    String redirectLink;
    U user;
    try {
        user = getUserFromInvitationDto(dto, userId);
        redirectLink = getRedirectLinkFromInvitationDto(dto, id, token);
    } catch (NotExistException ex) {
        JsonResult result = new JsonResult<>(VALIDATION_ERROR);
        result.setErrorMessage(ex.getMessage());
        response.sendRedirect(INVITATION_HOME_PAGE);
        return result;
    }
    response.sendRedirect(redirectLink);
    return invitationAccept(dto, user);
}
Also used : InvitationActionWithTokenDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionWithTokenDTO) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 InvitationActionWithTokenDTO (com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionWithTokenDTO)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 ApiOperation (io.swagger.annotations.ApiOperation)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1