fix(auth): marking predicate verification result if user is not existing

This commit is contained in:
Karol Sójko
2022-07-25 20:32:34 +02:00
parent 3d284461f3
commit 40996f9d48
2 changed files with 10 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import {
DomainEventPublisherInterface,
PredicateVerificationRequestedEvent,
} from '@standardnotes/domain-events'
import { PredicateVerificationResult } from '@standardnotes/predicates'
import { inject, injectable } from 'inversify'
import { Logger } from 'winston'
@@ -28,7 +29,13 @@ export class PredicateVerificationRequestedEventHandler implements DomainEventHa
if (event.meta.correlation.userIdentifierType === 'email') {
const user = await this.userRepository.findOneByEmail(event.meta.correlation.userIdentifier)
if (user === null) {
this.logger.warn(`Could not find user ${event.meta.correlation.userIdentifier} for predicate verification`)
await this.domainEventPublisher.publish(
this.domainEventFactory.createPredicateVerifiedEvent({
predicate: event.payload.predicate,
predicateVerificationResult: PredicateVerificationResult.CouldNotBeDetermined,
userUuid,
}),
)
return
}