I am working on a website with Angular Dart and i'm trying to implement routing so i have defined the following routes as described in the documentation:
class Routes {
static final login = RouteDefinition(
routePath: RoutePaths.login,
component: login_component.LoginComponentNgFactory,
useAsDefault: true
);
static final downloads = RouteDefinition(
routePath: RoutePaths.downloads,
component: download_component.DownloadComponentNgFactory
);
static final management = RouteDefinition(
routePath: RoutePaths.management,
component: management_component.ManagementComponentNgFactory,
);
static final objects = RouteDefinition(
routePath: RoutePaths.objects,
component: object_component.ObjectComponentNgFactory
);
static final reports = RouteDefinition(
routePath: RoutePaths.reports,
component: report_bug_component.ReportBugComponentNgFactory
);
static final settings = RouteDefinition(
routePath: RoutePaths.settings,
component: settings_component.SettingsComponentNgFactory
);
static final all = <RouteDefinition>[
login,
downloads,
management,
objects,
reports,
settings
];
}
I have set the login page to be the default route, but i want to prevent users from going to different routes before they login. So in case a user goes to URL/downloads before they logged in i want to redirect them to the login page. I read that this is possible in Angular Typescript by adding a CanActivate: [AuthGuard] to the routes, but this doesn't seem possible with Angular Dart. Does anyone know another way to achieve this?