Replies: 5 comments 4 replies
-
there isn't a way to nest or combine multiple |
Beta Was this translation helpful? Give feedback.
-
Here is what I am doing today -- currently [email protected] My app is using my_auth package where I have encapsulated all of my authentication logic and ux into its own package. The app's router is augmented with routes it pulls from the my_auth package using the function final appRouter = GoRouter(
routes: [
GoRoute(
path: '/',
redirect: (_) => '/home',
),
GoRoute(
path: '/home',
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
child: const HomePage(),
),
),
getAuthRoutes(wrapper: authWrapper),
],
errorPageBuilder: (context, state) => MaterialPage<void>(
key: state.pageKey,
child: ErrorPage(error: state.error),
),
redirect: _guard, // if not logged in, redirect to /auth/signin (with 2.0, it will be redirected to 'auth_signin')
) The my_auth package, exports the
Because I want my auth package may need its own observers (or custom error handler, or some other property of the However, the current API constricts me a bit when I do this. I never intend for anyone to navigate to the dummy Perhaps my use case is supported if |
Beta Was this translation helpful? Give feedback.
-
interesting. I like the idea of splitting routes along w/ notifications, etc. into packages. however, I'm not sure I understand your code. what does |
Beta Was this translation helpful? Give feedback.
-
maybe a lint to some sample code in a git repo? |
Beta Was this translation helpful? Give feedback.
-
Thanks, @oravecz. My definition of "minimal" is the smallest amount of code that shows the error you're seeing. It should be a throw-away project that you're willing to make public because it doesn't have any of your private IP in it. Anything with your IP in it isn't something I'm able to look at. |
Beta Was this translation helpful? Give feedback.
-
I do all of my auth routing (and services/ux) in a package imported into my application. So, I declare my routes for authentication in my package, and my routes for my app in the app.
In my application, I use the router like this:
And in my auth package, I export the authRoutes
I want all my auth routes to be top level routes, however if I want them to have their own guard or react to an observable login provider, I cannot do that unless I wrap them in a
GoRouter(...)
class where I can provide those properties. However, if I do that, I have to give that outerGoRouter()
class a path. Since I don't want my existing authentication paths to be under a path like 'auth/' is there a way for me to accomplish this?Beta Was this translation helpful? Give feedback.
All reactions