evaluateRouteGuards function
Future<bool>
evaluateRouteGuards(
- List<
PlexRouteGuard> guards, - String? rule,
- PlexRouteContext context
Evaluates guards for a route. If guards is empty and rule is set, uses PlexRoleGuard.
Returns true if the route is allowed, false if any guard redirects.
Implementation
Future<bool> evaluateRouteGuards(
List<PlexRouteGuard> guards,
String? rule,
PlexRouteContext context,
) async {
final effectiveGuards =
guards.isEmpty && rule != null ? [PlexRoleGuard(rule)] : guards;
for (final guard in effectiveGuards) {
final redirect = await guard.redirect(context);
if (redirect != null) return false;
}
return true;
}