use of uk.gov.di.authentication.shared.entity.TermsAndConditions in project di-authentication-api by alphagov.
the class DynamoService method updateTermsAndConditions.
@Override
public void updateTermsAndConditions(String email, String version) {
TermsAndConditions termsAndConditions = new TermsAndConditions(version, LocalDateTime.now(ZoneId.of("UTC")).toString());
userProfileMapper.save(userProfileMapper.load(UserProfile.class, email.toLowerCase(Locale.ROOT)).setTermsAndConditions(termsAndConditions));
}
use of uk.gov.di.authentication.shared.entity.TermsAndConditions in project di-authentication-api by alphagov.
the class SignUpHandler method handleRequestWithUserContext.
@Override
public APIGatewayProxyResponseEvent handleRequestWithUserContext(APIGatewayProxyRequestEvent input, Context context, SignupRequest request, UserContext userContext) {
attachSessionIdToLogs(userContext.getSession());
attachLogFieldToLogs(PERSISTENT_SESSION_ID, extractPersistentIdFromHeaders(input.getHeaders()));
attachLogFieldToLogs(CLIENT_ID, userContext.getClient().map(ClientRegistry::getClientID).orElse("unknown"));
LOG.info("Received request");
Optional<ErrorResponse> passwordValidationErrors = ValidationHelper.validatePassword(request.getPassword());
if (passwordValidationErrors.isEmpty()) {
if (authenticationService.userExists(request.getEmail())) {
auditService.submitAuditEvent(FrontendAuditableEvent.CREATE_ACCOUNT_EMAIL_ALREADY_EXISTS, context.getAwsRequestId(), userContext.getSession().getSessionId(), userContext.getClient().map(ClientRegistry::getClientID).orElse(AuditService.UNKNOWN), AuditService.UNKNOWN, request.getEmail(), IpAddressHelper.extractIpAddress(input), AuditService.UNKNOWN, PersistentIdHelper.extractPersistentIdFromHeaders(input.getHeaders()));
return generateApiGatewayProxyErrorResponse(400, ErrorResponse.ERROR_1009);
}
authenticationService.signUp(request.getEmail(), request.getPassword(), new Subject(), new TermsAndConditions(configurationService.getTermsAndConditionsVersion(), LocalDateTime.now(ZoneId.of("UTC")).toString()));
var consentRequired = ConsentHelper.userHasNotGivenConsent(userContext);
auditService.submitAuditEvent(FrontendAuditableEvent.CREATE_ACCOUNT, context.getAwsRequestId(), userContext.getSession().getSessionId(), userContext.getClient().map(ClientRegistry::getClientID).orElse(AuditService.UNKNOWN), AuditService.UNKNOWN, request.getEmail(), IpAddressHelper.extractIpAddress(input), AuditService.UNKNOWN, PersistentIdHelper.extractPersistentIdFromHeaders(input.getHeaders()));
sessionService.save(userContext.getSession().setEmailAddress(request.getEmail()).setNewAccount(NEW));
LOG.info("Successfully processed request");
try {
return generateApiGatewayProxyResponse(200, new SignUpResponse(consentRequired));
} catch (JsonException e) {
return generateApiGatewayProxyErrorResponse(400, ErrorResponse.ERROR_1001);
}
} else {
return generateApiGatewayProxyErrorResponse(400, passwordValidationErrors.get());
}
}
use of uk.gov.di.authentication.shared.entity.TermsAndConditions in project di-authentication-api by alphagov.
the class LoginHandlerTest method generateUserProfile.
private UserProfile generateUserProfile(String legacySubjectId) {
LocalDateTime localDateTime = LocalDateTime.now();
Date currentDateTime = Date.from(localDateTime.atZone(ZoneId.of("UTC")).toInstant());
return new UserProfile().setEmail(EMAIL).setEmailVerified(true).setPhoneNumber(PHONE_NUMBER).setPhoneNumberVerified(true).setPublicSubjectID(new Subject().getValue()).setSubjectID(new Subject().getValue()).setLegacySubjectID(legacySubjectId).setTermsAndConditions(new TermsAndConditions("1.0", currentDateTime.toString()));
}
use of uk.gov.di.authentication.shared.entity.TermsAndConditions in project di-authentication-api by alphagov.
the class UserStoreExtension method signUp.
public String signUp(String email, String password, Subject subject) {
TermsAndConditions termsAndConditions = new TermsAndConditions("1.0", LocalDateTime.now(ZoneId.of("UTC")).toString());
dynamoService.signUp(email, password, subject, termsAndConditions);
return dynamoService.getUserProfileByEmail(email).getPublicSubjectID();
}
Aggregations