use of com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO in project AuthGuard by AuthGuard.
the class PasswordlessRoute method verify.
public void verify(final Context context) {
final PasswordlessRequestDTO request = passwordlessRequestBodyHandler.getValidated(context);
final RequestContextBO requestContext = RequestContextExtractor.extractWithoutIdempotentKey(context);
final AuthResponseBO generatedTokens = passwordlessService.authenticate(request.getToken(), requestContext);
context.json(generatedTokens);
}
use of com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO in project AuthGuard by AuthGuard.
the class PasswordlessRequestValidatorTest method validateValid.
@Test
void validateValid() {
final PasswordlessRequestDTO request = PasswordlessRequestDTO.builder().token("token").build();
final Validator<PasswordlessRequestDTO> validator = Validators.getForClass(PasswordlessRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
use of com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO in project AuthGuard by AuthGuard.
the class PasswordlessRequestValidatorTest method validateMissingFields.
@Test
void validateMissingFields() {
final PasswordlessRequestDTO request = PasswordlessRequestDTO.builder().build();
final Validator<PasswordlessRequestDTO> validator = Validators.getForClass(PasswordlessRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).contains(new Violation("token", ViolationType.MISSING_REQUIRED_VALUE));
}
Aggregations