private async Task SaveNewRecordIfWithinVerificationLimit(string pseudonym, VerificationResult verificationResult) { if (!verificationResult.VerificationLimitExceeded) { // Save new record of non-limited verification await _verificationRecordsRepository.SaveNewRecord(new VerificationRecord(pseudonym)); } }
private async Task <VerificationResult> CreatePositiveVerificationResult(PositiveTestResult testResult, string pseudonym, IEnumerable <VerificationRecord> existingRecords) { _logger.LogDebug("Creating verified positive result for identified user"); var verificationResult = new VerificationResult(testResult, existingRecords, _verificationLimit); if (!verificationResult.VerificationLimitExceeded) { // Save new record of non-limited verification await _verificationRecordsRepository.SaveNewRecord(new VerificationRecord(pseudonym)); } return(verificationResult); }
public async Task <VerificationResult> Handle(Command request, CancellationToken cancellationToken) { var existingRecords = await _verificationRecordsRepository.RetrieveRecordsForPseudonym(request.Pseudonym, _verificationLimit.RecordsCutoff); var newRecord = new VerificationRecord(request.Pseudonym); var verificationRecords = existingRecords.Concat(new[] { newRecord }); _logger.LogInformation("Creating verified positive result for pin user"); var verificationResult = new VerificationResult(new PositiveTestResult(), verificationRecords, _verificationLimit); await _verificationRecordsRepository.SaveNewRecord(newRecord); return(verificationResult); }
private async Task <User> CreatePositiveUser(PositiveTestResult testResult, Command request) { var userIdClaim = FindUserIdClaim(request.ExternalClaims).ValueOr(() => throw new Exception("Unable to determine user-ID from external claims from provider: " + request.Provider)); var pseudonym = _pseudonymFactory.Create(request.Provider + ":" + userIdClaim.Value); var existingRecords = await _verificationRecordsRepository.RetrieveRecordsForPseudonym(pseudonym); var newRecord = new VerificationRecord(pseudonym); var verificationRecords = existingRecords.Concat(new[] { newRecord }); _logger.LogInformation("Verified positive user created after ID-porten login and MSIS lookup"); var postiveUser = new PositiveUser(request.Provider, userIdClaim.Value, testResult, verificationRecords, _verificationLimit); await _verificationRecordsRepository.SaveNewRecord(newRecord); return(postiveUser); }