aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-05-22 09:45:40 -0600
committerIván Ávalos <avalos@disroot.org>2023-05-22 09:45:40 -0600
commit9139a65003d758b4ee52758149b178d8dc990e0e (patch)
treea7d6aeb650e7c42050a99d50578a1b257cc29466
parentb43b43411cf2a06bbb4af0761d8acf2807718945 (diff)
downloadlinkchat-9139a65003d758b4ee52758149b178d8dc990e0e.tar.gz
linkchat-9139a65003d758b4ee52758149b178d8dc990e0e.tar.bz2
linkchat-9139a65003d758b4ee52758149b178d8dc990e0e.zip
Arreglos al flujo de autenticación
-rw-r--r--lib/main.dart25
-rw-r--r--lib/screens/dashboard_screen.dart7
-rw-r--r--lib/screens/login_screen.dart6
-rw-r--r--lib/screens/register_screen.dart2
4 files changed, 22 insertions, 18 deletions
diff --git a/lib/main.dart b/lib/main.dart
index 8baaa61..97a8fb4 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -52,19 +52,18 @@ class LinkChat extends StatelessWidget {
final ThemeProvider provider = context.watch<ThemeProvider>();
final ThemeData? theme = provider.theme;
provider.syncFromPrefs();
- return MaterialApp(
- theme: theme ?? ThemeSettings.lightTheme,
- darkTheme: theme ?? ThemeSettings.darkTheme,
- themeMode: ThemeMode.system,
- routes: getApplicationRoutes(),
- // initialRoute: '/login',
- home: StreamBuilder(
- stream: _auth.userChanges,
- builder: (context, snapshot) {
- return (snapshot.hasData && !snapshot.data!.isAnonymous)
+ return StreamBuilder(
+ stream: _auth.userChanges,
+ builder: (context, snapshot) {
+ return MaterialApp(
+ theme: theme ?? ThemeSettings.lightTheme,
+ darkTheme: theme ?? ThemeSettings.darkTheme,
+ themeMode: ThemeMode.system,
+ routes: getApplicationRoutes(),
+ home: (snapshot.hasData && !snapshot.data!.isAnonymous)
? const DashboardScreen()
- : const LoginScreen();
- },
- ));
+ : const LoginScreen(),
+ );
+ });
}
}
diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart
index 778c2bb..88bd8e7 100644
--- a/lib/screens/dashboard_screen.dart
+++ b/lib/screens/dashboard_screen.dart
@@ -93,10 +93,15 @@ class _DashboardScreenState extends State<DashboardScreen> {
}
void signOut(BuildContext context) {
- _auth.signOut().then((success) {
+ /*_auth.signOut().then((success) {
if (success) {
Navigator.of(context).popUntil(ModalRoute.withName('/login'));
}
+ });*/
+ _auth.signOut().then((success) {
+ if (success) {
+ Navigator.of(context).pushReplacementNamed('/login');
+ }
});
}
}
diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart
index 44cef6f..f00328b 100644
--- a/lib/screens/login_screen.dart
+++ b/lib/screens/login_screen.dart
@@ -117,7 +117,7 @@ class _LoginScreenState extends State<LoginScreen>
isLoading = false;
});
// TODO: checar si el resultado es true
- Navigator.of(context).pushNamed('/dash');
+ Navigator.of(context).pushReplacementNamed('/dash');
});
}
@@ -127,7 +127,7 @@ class _LoginScreenState extends State<LoginScreen>
isLoading = false;
});
if (success) {
- Navigator.of(context).pushNamed('/dash');
+ Navigator.of(context).pushReplacementNamed('/dash');
}
});
}
@@ -138,7 +138,7 @@ class _LoginScreenState extends State<LoginScreen>
isLoading = false;
});
if (success) {
- Navigator.of(context).pushNamed('/dash');
+ Navigator.of(context).pushReplacementNamed('/dash');
}
});
}
diff --git a/lib/screens/register_screen.dart b/lib/screens/register_screen.dart
index 349cac0..9a11923 100644
--- a/lib/screens/register_screen.dart
+++ b/lib/screens/register_screen.dart
@@ -169,7 +169,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
)
.then((success) {
if (success) {
- Navigator.of(context).pushNamed('/onboard');
+ Navigator.of(context).pushReplacementNamed('/onboard');
}
});
}