forked from baron/baron-sso
Merge remote-tracking branch 'origin/main' into dev/mypage
This commit is contained in:
@@ -10,6 +10,8 @@ import 'features/auth/presentation/login_screen.dart';
|
||||
import 'features/auth/presentation/signup_screen.dart';
|
||||
import 'features/auth/presentation/approve_qr_screen.dart';
|
||||
import 'features/auth/presentation/qr_scan_screen.dart';
|
||||
import 'features/auth/presentation/forgot_password_screen.dart';
|
||||
import 'features/auth/presentation/reset_password_screen.dart';
|
||||
import 'features/dashboard/presentation/dashboard_screen.dart';
|
||||
import 'features/admin/presentation/user_management_screen.dart';
|
||||
import 'features/profile/presentation/pages/profile_page.dart';
|
||||
@@ -111,6 +113,23 @@ final _router = GoRouter(
|
||||
return LoginScreen(verificationToken: token);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/forgot-password',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /forgot-password");
|
||||
return const ForgotPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
// Supports both /reset-password and /reset-password?token=...
|
||||
path: '/reset-password',
|
||||
builder: (context, state) {
|
||||
// For deep linking, you might pass the token in the path, e.g., /reset-password/:token
|
||||
// final token = state.pathParameters['token'];
|
||||
_routerLogger.info("Navigating to /reset-password");
|
||||
return const ResetPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/approve',
|
||||
builder: (context, state) {
|
||||
@@ -143,26 +162,29 @@ final _router = GoRouter(
|
||||
final isPublicPath = path == '/login' ||
|
||||
path == '/signup' ||
|
||||
path.startsWith('/verify/') ||
|
||||
path == '/approve';
|
||||
path == '/approve' ||
|
||||
path == '/forgot-password' ||
|
||||
path == '/reset-password';
|
||||
|
||||
_routerLogger.fine("Redirect check - Path: $path, IsLoggedIn: $isLoggedIn");
|
||||
|
||||
// 0. ALWAYS allow /verify/ to proceed so it can signal the backend
|
||||
if (path.startsWith('/verify/')) {
|
||||
// 0. ALWAYS allow public paths to proceed so they can function
|
||||
if (isPublicPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If not logged in and trying to access a protected page, redirect to /login
|
||||
if (!isLoggedIn && !isPublicPath) {
|
||||
if (!isLoggedIn) {
|
||||
_routerLogger.info("Not logged in, redirecting to /login");
|
||||
return '/login';
|
||||
}
|
||||
|
||||
// If logged in and trying to access login page, redirect to root (dashboard)
|
||||
if (isLoggedIn && path == '/login') {
|
||||
_routerLogger.info("Logged in, redirecting to /");
|
||||
return '/';
|
||||
}
|
||||
// This is now implicitly handled by the isPublicPath check, but kept for clarity.
|
||||
// if (isLoggedIn && path == '/login') {
|
||||
// _routerLogger.info("Logged in, redirecting to /");
|
||||
// return '/';
|
||||
// }
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user