From 96dc456ff43c62d82303fa1d570b349eef068fd4 Mon Sep 17 00:00:00 2001 From: Username1548 Date: Wed, 5 Mar 2025 14:26:16 +0700 Subject: [PATCH] added invalid token chicking --- .../.kotlin/errors/errors-1740999625028.log | 4 + ios/Runner.xcodeproj/project.pbxproj | 23 +++- ios/Runner/Info.plist | 119 +++++++++--------- ios/Runner/Runner.entitlements | 8 ++ lib/core/app_router.dart | 22 +++- lib/core/const.dart | 4 +- lib/core/token_storage.dart | 2 +- pubspec.yaml | 3 +- 8 files changed, 111 insertions(+), 74 deletions(-) create mode 100644 android/.kotlin/errors/errors-1740999625028.log create mode 100644 ios/Runner/Runner.entitlements diff --git a/android/.kotlin/errors/errors-1740999625028.log b/android/.kotlin/errors/errors-1740999625028.log new file mode 100644 index 00000000..1219b509 --- /dev/null +++ b/android/.kotlin/errors/errors-1740999625028.log @@ -0,0 +1,4 @@ +kotlin version: 2.0.21 +error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output: + 1. Kotlin compile daemon is ready + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index e7e549aa..a87c031c 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9D8D6181877DE17809AFF936 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; DF0C4038A57E19D3ABA03C15 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + FEE92A0E2D772EA300E6E989 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -112,6 +113,7 @@ 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + FEE92A0E2D772EA300E6E989 /* Runner.entitlements */, ); path = Runner; sourceTree = ""; @@ -362,9 +364,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 16; - DEVELOPMENT_TEAM = VL68C36HYS; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -385,6 +389,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Eatvio distribution profile"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -511,9 +516,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 16; - DEVELOPMENT_TEAM = VL68C36HYS; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -534,6 +541,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Eatvio distribution profile"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -548,9 +556,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 16; - DEVELOPMENT_TEAM = VL68C36HYS; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -571,6 +581,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Eatvio distribution profile"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 751ec180..d5b22884 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -1,67 +1,66 @@ + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + eatvio_app + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + NSAppTransportSecurity - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - eatvio_app - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS + NSAllowsArbitraryLoads - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - NSPhotoLibraryUsageDescription - Нужно для загрузки фото - NSCameraUsageDescription - Нужно для загрузки фото - UIBackgroundModes - - fetch - remote-notification - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSLocationWhenInUseUsageDescription - - UIStatusBarHidden - + NSCameraUsageDescription + Нужно для загрузки фото + NSLocationWhenInUseUsageDescription + + NSPhotoLibraryUsageDescription + Нужно для загрузки фото + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + fetch + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements new file mode 100644 index 00000000..a9bc4abe --- /dev/null +++ b/ios/Runner/Runner.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + disabled + + diff --git a/lib/core/app_router.dart b/lib/core/app_router.dart index eed56e2c..bf988f64 100644 --- a/lib/core/app_router.dart +++ b/lib/core/app_router.dart @@ -1,6 +1,10 @@ +import 'dart:developer'; + +import 'package:dio/dio.dart'; import 'package:eatvio_app/core/websockets/ws_manager.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/token_storage.dart'; +import 'package:eatvio_app/core/websockets/ws_service.dart'; import 'package:eatvio_app/features/auth/presentation/pages/auth_screen.dart'; import 'package:eatvio_app/features/blog_post/presentation/pages/blog_post_screen.dart'; import 'package:eatvio_app/features/blog_post_create/presentation/pages/blog_post_create_screen.dart'; @@ -70,9 +74,19 @@ class AppRouter { redirect: (context, state) async { // TokenStorage.removeTokenInStorage(); // await TokenStorage.saveTokenInStorage('Bearer 3|laravel_sanctum_zoubsO9NPXAqgLZEdHV9R3XbuDUHJJMJyXcd77mhbb649f04'); - if (await TokenStorage.haveTokenInStorage()) { - return '/my-profile-screen'; + final token = await TokenStorage.getTokenFromStorage(); + if (token != null) { + try { + await sl().getWebsocket(); + return '/my-profile-screen'; + } on DioException catch (e, st) { + if (e.response?.statusCode == 401 && e.response?.statusMessage == 'Unauthenticated.') { + TokenStorage.removeTokenInStorage(); + } + log(e.toString(), stackTrace: st); + } } + return null; }, builder: (context, state) => const AuthScreen(), @@ -111,7 +125,9 @@ class AppRouter { await sl().initialize(); return null; }, - pageBuilder: (context, state) => NoTransitionPage(child: ProfileScreen()), + pageBuilder: (context, state) { + return NoTransitionPage(child: ProfileScreen()); + }, ), GoRoute( path: '/feed-screen', diff --git a/lib/core/const.dart b/lib/core/const.dart index 4e8b3650..dfeae1fc 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,5 +1,5 @@ -// String baseUrl = 'https://eatvio.ru'; -String baseUrl = 'https://dev2.eatvio.com'; +String baseUrl = 'https://eatvio.ru'; +// String baseUrl = 'https://dev2.eatvio.com'; const List durationValues = [7, 14, 21]; diff --git a/lib/core/token_storage.dart b/lib/core/token_storage.dart index 9332ceb5..017931c4 100644 --- a/lib/core/token_storage.dart +++ b/lib/core/token_storage.dart @@ -20,7 +20,7 @@ abstract class TokenStorage { } } - static Future getTokenFromStorage() async => (await FlutterSecureStorage().read(key: 'token'))!; + static Future getTokenFromStorage() async => await FlutterSecureStorage().read(key: 'token'); static saveTokenInStorage(String token) async { await FlutterSecureStorage().write(key: 'token', value: token); diff --git a/pubspec.yaml b/pubspec.yaml index a7d1a446..652a2efd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: eatvio_app description: A new Flutter project. -version: 1.0.40+40 +version: 1.0.41+40 publish_to: 'none' environment: @@ -66,7 +66,6 @@ dependencies: dependency_overrides: intl: ^0.19.0 connectivity_plus: ^6.1.2 - dev_dependencies: build_runner: ^2.4.15