canActivate method
Determines whether navigation to the matched route should be allowed, redirected, or denied.
Implementation
@override
FutureOr<GuardResult> canActivate(BuildContext context, BloomRouteMatch match) {
final activeAuth = auth ?? injectOrNull<BloomAuthBase>();
if (activeAuth == null || !activeAuth.isAuthenticated.value) {
final currentUri = Uri.encodeComponent(match.location);
final redirect = '$loginPath?from=$currentUri';
return GuardResult.redirect(redirect);
}
return GuardResult.allow();
}