forked from baron/baron-sso
root page 변경
This commit is contained in:
@@ -69,9 +69,16 @@ final _router = GoRouter(
|
||||
refreshListenable: AuthNotifier.instance,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
path: '/',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to root (LoginScreen)");
|
||||
_routerLogger.info("Navigating to root (DashboardScreen)");
|
||||
return const DashboardScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /login");
|
||||
return const LoginScreen();
|
||||
}
|
||||
),
|
||||
@@ -91,13 +98,6 @@ final _router = GoRouter(
|
||||
return ApproveQrScreen(pendingRef: ref);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/dashboard',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /dashboard");
|
||||
return const DashboardScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/scan',
|
||||
builder: (context, state) {
|
||||
@@ -117,17 +117,24 @@ final _router = GoRouter(
|
||||
final isLoggedIn =
|
||||
Descope.sessionManager.session?.refreshToken.isExpired == false;
|
||||
final path = state.uri.path;
|
||||
final isLoggingIn = path == '/' || path.startsWith('/verify/') || path.startsWith('/admin/') || path == '/approve';
|
||||
|
||||
// Public paths that don't require login
|
||||
final isPublicPath = path == '/login' ||
|
||||
path.startsWith('/verify/') ||
|
||||
path == '/approve';
|
||||
|
||||
_routerLogger.fine("Redirect check - Path: $path, IsLoggedIn: $isLoggedIn");
|
||||
|
||||
if (!isLoggedIn && !isLoggingIn) {
|
||||
_routerLogger.info("Not logged in, redirecting to /");
|
||||
return '/';
|
||||
// If not logged in and trying to access a protected page, redirect to /login
|
||||
if (!isLoggedIn && !isPublicPath) {
|
||||
_routerLogger.info("Not logged in, redirecting to /login");
|
||||
return '/login';
|
||||
}
|
||||
if (isLoggedIn && path == '/') {
|
||||
_routerLogger.info("Logged in, redirecting to /dashboard");
|
||||
return '/dashboard';
|
||||
|
||||
// If logged in and trying to access login page, redirect to root (dashboard)
|
||||
if (isLoggedIn && (path == '/login' || path.startsWith('/verify/'))) {
|
||||
_routerLogger.info("Logged in, redirecting to /");
|
||||
return '/';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user