Refactor event bus and queue system; detect cycles in DI realization and make
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-01-26 19:37:54 -06:00
parent 506fb55c74
commit 6d1cf18680
69 changed files with 1673 additions and 720 deletions

View File

@@ -1,10 +1,10 @@
import {Inject, Injectable} from '../../di'
import {EventBus} from '../../event/EventBus'
import {Awaitable, Maybe} from '../../util'
import {Authenticatable, AuthenticatableRepository} from '../types'
import {Logging} from '../../service/Logging'
import {UserAuthenticatedEvent} from '../event/UserAuthenticatedEvent'
import {UserFlushedEvent} from '../event/UserFlushedEvent'
import {Bus} from '../../support/bus'
/**
* Base-class for a context that authenticates users and manages security.
@@ -12,7 +12,7 @@ import {UserFlushedEvent} from '../event/UserFlushedEvent'
@Injectable()
export abstract class SecurityContext {
@Inject()
protected readonly bus!: EventBus
protected readonly bus!: Bus
@Inject()
protected readonly logging!: Logging
@@ -40,7 +40,7 @@ export abstract class SecurityContext {
*/
async authenticateOnce(user: Authenticatable): Promise<void> {
this.authenticatedUser = user
await this.bus.dispatch(new UserAuthenticatedEvent(user, this))
await this.bus.push(new UserAuthenticatedEvent(user, this))
}
/**
@@ -50,7 +50,7 @@ export abstract class SecurityContext {
async authenticate(user: Authenticatable): Promise<void> {
this.authenticatedUser = user
await this.persist()
await this.bus.dispatch(new UserAuthenticatedEvent(user, this))
await this.bus.push(new UserAuthenticatedEvent(user, this))
}
/**
@@ -60,7 +60,7 @@ export abstract class SecurityContext {
const user = this.authenticatedUser
if ( user ) {
this.authenticatedUser = undefined
await this.bus.dispatch(new UserFlushedEvent(user, this))
await this.bus.push(new UserFlushedEvent(user, this))
}
}
@@ -72,7 +72,7 @@ export abstract class SecurityContext {
if ( user ) {
this.authenticatedUser = undefined
await this.persist()
await this.bus.dispatch(new UserFlushedEvent(user, this))
await this.bus.push(new UserFlushedEvent(user, this))
}
}

View File

@@ -32,7 +32,7 @@ export class SessionSecurityContext extends SecurityContext {
const user = await this.repository.getByIdentifier(identifier)
if ( user ) {
this.authenticatedUser = user
await this.bus.dispatch(new UserAuthenticationResumedEvent(user, this))
await this.bus.push(new UserAuthenticationResumedEvent(user, this))
}
}
}