feat(auth): add removing authenticator

This commit is contained in:
Karol Sójko
2022-12-29 13:55:08 +01:00
parent 401b78e477
commit de50d76800
13 changed files with 176 additions and 3 deletions
@@ -1,4 +1,4 @@
import { MapperInterface, Uuid } from '@standardnotes/domain-core'
import { MapperInterface, UniqueEntityId, Uuid } from '@standardnotes/domain-core'
import { Repository } from 'typeorm'
import { Authenticator } from '../../Domain/Authenticator/Authenticator'
@@ -11,6 +11,25 @@ export class MySQLAuthenticatorRepository implements AuthenticatorRepositoryInte
private mapper: MapperInterface<Authenticator, TypeORMAuthenticator>,
) {}
async findById(id: UniqueEntityId): Promise<Authenticator | null> {
const persistence = await this.ormRepository
.createQueryBuilder('authenticator')
.where('authenticator.uuid = :id', {
id: id.toString(),
})
.getOne()
if (persistence === null) {
return null
}
return this.mapper.toDomain(persistence)
}
async remove(authenticator: Authenticator): Promise<void> {
await this.ormRepository.remove(this.mapper.toProjection(authenticator))
}
async findByUserUuidAndCredentialId(userUuid: Uuid, credentialId: Buffer): Promise<Authenticator | null> {
const persistence = await this.ormRepository
.createQueryBuilder('authenticator')