mirror of
https://github.com/standardnotes/server
synced 2026-10-21 15:03:42 -04:00
feat(auth): add removing authenticator
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user