I have an Aurelia app using Aurelia Store. I'm having some trouble when using the @connectTo
decorator in an Aurelia pipeline step.
I have added the following step to my config pipeline:
config.addPipelineStep('authorize', AuthorizeStep);
And this step looks like:
@connectTo()
export class AuthorizeStep {
state: State;
run(navigationInstruction, next) {
if (navigationInstruction.getAllInstructions().find(x => x.config.isAdmin))
{
if (!this.state.user.isAdmin) {
return next.cancel();
}
}
return next();
}
}
However, my state is always undefined. Looking at other parts of my project, I can see the state and user are being populated, but it seems like in this AuthorizeStep
it doesn't seem to work.
I think this issue may be due to the fact that my AuthorizeStep
doesn't have a bind
lifecycle method, but if so, what can I do about this?