4
ルータに承認パイプラインステップを追加しました。すべて正常に動作しますが、Redirect
クラスを使用してユーザーをログインページに誘導すると、引数としてURLが使用されます。 Router.navigateToRoute()
を使用していた場合は、ルート名を渡すことをお勧めします。これは可能ですか?いくつかのグーグル後Aurelia Redirectクラスの使用
@inject(AuthService)
class AuthorizeStep {
constructor (authService) {
this.authService = authService;
}
run (navigationInstruction, next) {
if (navigationInstruction.getAllInstructions().some(i => i.config.auth)) {
if (!this.authService.isLoggedIn) {
return next.cancel(new Redirect('url-to-login-page')); // Would prefer to use the name of route; 'login', instead.
}
}
return next();
}
}