From 8282d49064e94034768531d2f30108b08dce156f Mon Sep 17 00:00:00 2001 From: BLoC Date: Wed, 12 Feb 2025 17:21:19 +0300 Subject: [PATCH] fix: reg in webview --- lib/features/auth/auth_screen/auth_screen.dart | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/features/auth/auth_screen/auth_screen.dart b/lib/features/auth/auth_screen/auth_screen.dart index eebe03ac..998cfc76 100644 --- a/lib/features/auth/auth_screen/auth_screen.dart +++ b/lib/features/auth/auth_screen/auth_screen.dart @@ -76,18 +76,22 @@ class _AuthScreenState extends State { ..setNavigationDelegate( NavigationDelegate( onPageFinished: (String url) async { + final bool tokenInStorage = await TokenStorage.haveTokenInStorage(); + final bool credentialsInStorage = await CredentialsStorage.haveCredentialsInStorage(); + if (needLogout) { await logoutFromWeb(); needLogout = false; } else if (!url.contains('profile') && !url.contains('registration')) { await _controller.runJavaScript(jsChannelAuthScript); } else if (url.contains('profile')) { - await CredentialsStorage.saveCredentials(email, password); - await loginInApplication(); + if (credentialsInStorage) { + await CredentialsStorage.saveCredentials(email, password); + await loginInApplication(); + } else { + await logoutFromWeb(); + } } else { - final bool tokenInStorage = await TokenStorage.haveTokenInStorage(); - final bool credentialsInStorage = await CredentialsStorage.haveCredentialsInStorage(); - if (tokenInStorage && credentialsInStorage) { GoRouter.of(context).go('/my-profile-screen'); } else if (!tokenInStorage && credentialsInStorage) {