Route - prevent pre/post middleware from being applied twice
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-06-29 00:34:05 -05:00
parent 7506d6567d
commit faa8a31102
2 changed files with 10 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import {SessionSecurityContext} from '../contexts/SessionSecurityContext'
import {SecurityContext} from '../SecurityContext'
import {ORMUserRepository} from '../orm/ORMUserRepository'
import {AuthConfig, AuthenticatableRepositories} from '../config'
import {Logging} from '../../service/Logging'
/**
* Injects a SessionSecurityContext into the request and attempts to
@@ -17,7 +18,11 @@ export class SessionAuthMiddleware extends Middleware {
@Inject()
protected readonly config!: Config
@Inject()
protected readonly logging!: Logging
async apply(): Promise<ResponseObject> {
this.logging.debug('Applying session auth middleware...')
const context = <SessionSecurityContext> this.make(SessionSecurityContext, this.getRepository())
this.request.registerSingletonInstance(SecurityContext, context)
await context.resume()