use of com.nexblocks.authguard.api.dto.requests.ActionTokenRequestDTO in project AuthGuard by AuthGuard.
the class ActionTokensRoute method createToken.
@Override
public void createToken(final Context context) {
final ActionTokenRequestDTO request = actionTokenRequestBodyHandler.getValidated(context);
final Try<ActionTokenBO> result;
if (request.getType() == ActionTokenRequestType.OTP) {
result = actionTokenService.generateFromOtp(request.getOtp().getPasswordId(), request.getOtp().getPassword(), request.getAction());
} else {
final AuthRequestBO authRequest = restMapper.toBO(request.getBasic());
result = actionTokenService.generateFromBasicAuth(authRequest, request.getAction());
}
if (result.isFailure()) {
throw (ServiceException) result.getCause();
}
context.status(201).json(restMapper.toDTO(result.get()));
}
Aggregations