Merge pull request 'main' (#226) from BLoC/eatvio_app:main into main

Reviewed-on: eatvio/eatvio_app#226
This commit is contained in:
BLoC
2025-02-12 14:24:22 +00:00

View File

@@ -76,18 +76,26 @@ class _AuthScreenState extends State<AuthScreen> {
..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 loginInApplication();
} else {
if (email.isNotEmpty && password.isNotEmpty) {
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) {