Aurelia: Wie binde ich während des Pipeline-Schritts eines Routers eine Variable an diesen Router?
Ich möchte den Benutzer weitergeben, der während des @ gefunden wurdAuthorizeStep
entweder zumApp class
und dann zumhome module
.
Hier ist was ich habe:
export class App {
configureRouter(config, router) {
config.addPipelineStep('authorize', AuthorizeStep);
config.map([
{route: ['', ':filter'], name: "", moduleId: 'welcome'}
{route: 'home', name: "home", moduleId: 'home' auth:true}
]);
this.router = router;
}
}
class AuthorizeStep {
run(routingContext, next) {
if (routingContext.nextInstructions.some(i => i.config.auth)) {
this.client.get('auth/login')
.then(response => {
this.user = response.content;
});
}
return next();
}
}