I have a project using aurelia-auth plugin. I would like to extend parts of the Authentication class so it can handle a more complex flow. All of my attempts to tell the DI system to use the CustomAuth class in its place are failing though. In particular, it seems Container.instance.registerSingleton doesn’t work how I expect from what the docs say:
myauth.js
import {Container, inject} from 'aurelia-framework';
import {Authentication} from 'aurelia-auth';
export class CustomAuth extends Authentication {
constructor(...rest){
super(...rest)
console.log('CustomAuth created')
}
}
Container.instance.registerSingleton(Authentication, CustomAuth);
export class CustomAuthService extends AuthService {
constructor(...rest){
super(...rest)
}
}
app.js
import {inject} from 'aurelia-framework';
import {AuthorizeStep, FetchConfig} from 'aurelia-auth';
import {CustomAuthService} from './myauth';
inject(CustomAuthService, FetchConfig);
export class App {
constructor(auth, fetchConfig){
this.auth = auth
this.fetchConfig = fetchConfig
}
activate() {
this.fetchConfig.configure();
}
configureRouter(config, router) {
config.addPipelineStep('authorize', AuthorizeStep);
}
//...
}
error I’m getting:
Error: key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?
Why does it thinks the key or value is missing?