/
opt
/
canhelp
/
apps
/
mobile
/
lib
/
routing
/
/opt/canhelp/apps/mobile/lib/routing
mkdir
upload
Name
Size
Mode
Actions
auth_redirect.dart
787
0644
edit
dl
rm
Edit:
/opt/canhelp/apps/mobile/lib/routing/auth_redirect.dart
(787B)
const defaultProtectedPaths = [ '/dashboard', '/profile', '/tasks/new', '/chat', '/notifications', '/favorites', '/schedule', '/admin', ]; String? resolveAuthRedirect({ required bool isAuthLoading, required bool isAuthenticated, required String matchedLocation, List<String> protectedPaths = defaultProtectedPaths, }) { if (isAuthLoading) return null; final loggingIn = matchedLocation == '/login' || matchedLocation == '/register' || matchedLocation == '/forgot-password' || matchedLocation == '/reset-password'; if (!isAuthenticated && !loggingIn) { if (protectedPaths.any((p) => matchedLocation.startsWith(p))) { return '/login'; } } if (isAuthenticated && loggingIn) { return '/'; } return null; }
Save
cmd:
run