1
0
forked from baron/baron-sso

root page 변경

This commit is contained in:
2026-01-20 11:22:07 +09:00
parent 8c5d87a5d2
commit 431e3a7e05
7 changed files with 37 additions and 30 deletions

View File

@@ -67,7 +67,7 @@ class _CreateUserScreenState extends State<CreateUserScreen> {
// If cancelled or empty // If cancelled or empty
if (inputPassword == null || inputPassword.isEmpty) { if (inputPassword == null || inputPassword.isEmpty) {
if (mounted) context.go('/dashboard'); // Kick out if (mounted) context.go('/'); // Kick out
return; return;
} }
@@ -88,7 +88,7 @@ class _CreateUserScreenState extends State<CreateUserScreen> {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Invalid Password. Access Denied.'), backgroundColor: Colors.red), const SnackBar(content: Text('Invalid Password. Access Denied.'), backgroundColor: Colors.red),
); );
context.go('/dashboard'); // Kick out context.go('/'); // Kick out
} }
} }
} }
@@ -152,7 +152,7 @@ class _CreateUserScreenState extends State<CreateUserScreen> {
title: const Text('Create User'), title: const Text('Create User'),
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
onPressed: () => context.go('/dashboard'), onPressed: () => context.go('/'),
), ),
), ),
body: Center( body: Center(

View File

@@ -78,7 +78,7 @@ class _UserManagementScreenState extends State<UserManagementScreen> with Single
); );
if (inputPassword == null || inputPassword.isEmpty) { if (inputPassword == null || inputPassword.isEmpty) {
if (mounted) context.go('/dashboard'); if (mounted) context.go('/');
return; return;
} }
@@ -97,7 +97,7 @@ class _UserManagementScreenState extends State<UserManagementScreen> with Single
} else { } else {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Invalid Password'), backgroundColor: Colors.red)); ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Invalid Password'), backgroundColor: Colors.red));
context.go('/dashboard'); context.go('/');
} }
} }
} }
@@ -277,7 +277,7 @@ class _UserManagementScreenState extends State<UserManagementScreen> with Single
title: const Text('User Management'), title: const Text('User Management'),
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
onPressed: () => context.go('/dashboard'), onPressed: () => context.go('/'),
), ),
bottom: TabBar( bottom: TabBar(
controller: _tabController, controller: _tabController,

View File

@@ -22,7 +22,7 @@ class _ApproveQrScreenState extends State<ApproveQrScreen> {
final session = Descope.sessionManager.session; final session = Descope.sessionManager.session;
if (session == null || session.refreshToken.isExpired) { if (session == null || session.refreshToken.isExpired) {
setState(() => _message = "Please log in on your phone first."); setState(() => _message = "Please log in on your phone first.");
context.go('/'); // Redirect to login context.go('/login'); // Redirect to login
return; return;
} }
@@ -43,7 +43,7 @@ class _ApproveQrScreenState extends State<ApproveQrScreen> {
// Automatically go to dashboard after a short delay // Automatically go to dashboard after a short delay
Future.delayed(const Duration(seconds: 1), () { Future.delayed(const Duration(seconds: 1), () {
if (mounted) context.go('/dashboard'); if (mounted) context.go('/');
}); });
} catch (e) { } catch (e) {
setState(() => _message = "Error: $e"); setState(() => _message = "Error: $e");
@@ -103,14 +103,14 @@ class _ApproveQrScreenState extends State<ApproveQrScreen> {
Padding( Padding(
padding: const EdgeInsets.only(top: 16), padding: const EdgeInsets.only(top: 16),
child: TextButton( child: TextButton(
onPressed: () => context.go('/'), onPressed: () => context.go('/login'),
child: const Text("Login on this device first"), child: const Text("Login on this device first"),
), ),
), ),
if (_success) if (_success)
FilledButton( FilledButton(
onPressed: () => context.go('/dashboard'), onPressed: () => context.go('/'),
child: const Text("Go to My Dashboard"), child: const Text("Go to My Dashboard"),
), ),
], ],

View File

@@ -409,7 +409,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
// We call notify() to update the router's state, and go() to ensure navigation. // We call notify() to update the router's state, and go() to ensure navigation.
AuthNotifier.instance.notify(); AuthNotifier.instance.notify();
if (mounted) { if (mounted) {
context.go('/dashboard'); context.go('/');
} }
} }

View File

@@ -34,7 +34,7 @@ class LoginSuccessScreen extends StatelessWidget {
// 이 버튼이 QR 카메라를 켜는 버튼입니다. // 이 버튼이 QR 카메라를 켜는 버튼입니다.
FilledButton.icon( FilledButton.icon(
onPressed: () { onPressed: () {
context.push('/qr-scan'); context.push('/scan');
}, },
icon: const Icon(Icons.camera_alt, size: 28), icon: const Icon(Icons.camera_alt, size: 28),
label: const Text("QR 인증 (카메라 켜기)"), label: const Text("QR 인증 (카메라 켜기)"),
@@ -50,7 +50,7 @@ class LoginSuccessScreen extends StatelessWidget {
const SizedBox(height: 24), const SizedBox(height: 24),
TextButton( TextButton(
onPressed: () { onPressed: () {
context.go('/dashboard'); context.go('/');
}, },
child: const Text("나중에 하기 (대시보드로 이동)", style: TextStyle(color: Colors.grey)), child: const Text("나중에 하기 (대시보드로 이동)", style: TextStyle(color: Colors.grey)),
), ),

View File

@@ -25,7 +25,7 @@ class DashboardScreen extends StatelessWidget {
return Scaffold( return Scaffold(
backgroundColor: Colors.grey[50], backgroundColor: Colors.grey[50],
appBar: AppBar( appBar: AppBar(
title: Text('Baron Launcher', style: GoogleFonts.outfit(fontWeight: FontWeight.bold)), title: Text('Baron SSO', style: GoogleFonts.outfit(fontWeight: FontWeight.bold)),
elevation: 0, elevation: 0,
backgroundColor: Colors.white, backgroundColor: Colors.white,
foregroundColor: Colors.black, foregroundColor: Colors.black,

View File

@@ -71,7 +71,14 @@ final _router = GoRouter(
GoRoute( GoRoute(
path: '/', path: '/',
builder: (context, state) { 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(); return const LoginScreen();
} }
), ),
@@ -91,13 +98,6 @@ final _router = GoRouter(
return ApproveQrScreen(pendingRef: ref); return ApproveQrScreen(pendingRef: ref);
}, },
), ),
GoRoute(
path: '/dashboard',
builder: (context, state) {
_routerLogger.info("Navigating to /dashboard");
return const DashboardScreen();
},
),
GoRoute( GoRoute(
path: '/scan', path: '/scan',
builder: (context, state) { builder: (context, state) {
@@ -117,17 +117,24 @@ final _router = GoRouter(
final isLoggedIn = final isLoggedIn =
Descope.sessionManager.session?.refreshToken.isExpired == false; Descope.sessionManager.session?.refreshToken.isExpired == false;
final path = state.uri.path; 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"); _routerLogger.fine("Redirect check - Path: $path, IsLoggedIn: $isLoggedIn");
if (!isLoggedIn && !isLoggingIn) { // If not logged in and trying to access a protected page, redirect to /login
_routerLogger.info("Not logged in, redirecting to /"); if (!isLoggedIn && !isPublicPath) {
return '/'; _routerLogger.info("Not logged in, redirecting to /login");
return '/login';
} }
if (isLoggedIn && path == '/') {
_routerLogger.info("Logged in, redirecting to /dashboard"); // If logged in and trying to access login page, redirect to root (dashboard)
return '/dashboard'; if (isLoggedIn && (path == '/login' || path.startsWith('/verify/'))) {
_routerLogger.info("Logged in, redirecting to /");
return '/';
} }
return null; return null;