Search in sources :

Example 1 with PasswordlessRequestDTO

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);
}
Also used : RequestContextBO(com.nexblocks.authguard.service.model.RequestContextBO) PasswordlessRequestDTO(com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO) AuthResponseBO(com.nexblocks.authguard.service.model.AuthResponseBO)

Example 2 with PasswordlessRequestDTO

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();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) PasswordlessRequestDTO(com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO) Test(org.junit.jupiter.api.Test)

Example 3 with PasswordlessRequestDTO

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));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) PasswordlessRequestDTO(com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO) Test(org.junit.jupiter.api.Test)

Aggregations

PasswordlessRequestDTO (com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO)3 Violation (com.nexblocks.authguard.api.dto.validation.violations.Violation)2 Test (org.junit.jupiter.api.Test)2 AuthResponseBO (com.nexblocks.authguard.service.model.AuthResponseBO)1 RequestContextBO (com.nexblocks.authguard.service.model.RequestContextBO)1