[Issue #7] Auth-protected app example #20

Merged
HugoNijhuis merged 2 commits from issue-7-auth-protected-example into main 2026-01-09 16:35:33 +00:00
Showing only changes of commit 7589011526 - Show all commits

View File

@@ -65,9 +65,20 @@ func main() {
handleOAuthCallback()
return
}
router := navigation.NewRouter(getRoutes())
router.SetNotFoundHandler(notFoundView)
navigation.SetGlobalRouter(router)
// Set up routes
routes := []navigation.Route{
// Create the main app with router
ui.NewAppWithRouter(router)
// Keep the application running
select {}
}
// getRoutes returns the route configuration for the application
func getRoutes() []navigation.Route {
return []navigation.Route{
{
Path: "/",
Handler: homeView,
@@ -87,16 +98,6 @@ func main() {
Guards: []navigation.RouteGuard{authGuard()},
},
}
router := navigation.NewRouter(routes)
router.SetNotFoundHandler(notFoundView)
navigation.SetGlobalRouter(router)
// Create the main app with router
ui.NewAppWithRouter(router)
// Keep the application running
select {}
}
// checkExistingSession checks for existing valid tokens
@@ -150,28 +151,7 @@ func handleOAuthCallback() {
// renderApp initializes and renders the app after callback processing
func renderApp() {
routes := []navigation.Route{
{
Path: "/",
Handler: homeView,
},
{
Path: "/callback",
Handler: callbackView,
},
{
Path: "/profile",
Handler: profileView,
Guards: []navigation.RouteGuard{authGuard()},
},
{
Path: "/protected",
Handler: protectedView,
Guards: []navigation.RouteGuard{authGuard()},
},
}
router := navigation.NewRouter(routes)
router := navigation.NewRouter(getRoutes())
router.SetNotFoundHandler(notFoundView)
navigation.SetGlobalRouter(router)