From 0b14621aab6d06eca8e3b27ce0725e633c459270 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 8 Aug 2024 21:20:12 +0900 Subject: [PATCH 1/6] =?UTF-8?q?M3-500=20Feat=20:=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- lib/controllers/map_controller.dart | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8e3ca5df..6ce5b0b2 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -51,7 +51,7 @@ Date: Thu, 8 Aug 2024 22:53:47 +0900 Subject: [PATCH 2/6] =?UTF-8?q?M3-237=20Feat=20:=20=EB=B0=B1=EA=B7=B8?= =?UTF-8?q?=EB=9D=BC=EC=9A=B4=EB=93=9C=20=EC=84=B1=EA=B3=B5(=EB=A6=AC?= =?UTF-8?q?=ED=94=84=EB=A0=88=EC=89=AC=20=EB=90=98=EC=97=88=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20secure=20storage=20=EC=97=90=EB=8A=94=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=90=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EC=9D=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/PrivacyInfo.xcprivacy | 57 ++++++++++++++++++++++++++++ ios/Runner.xcodeproj/project.pbxproj | 7 +++- lib/controllers/map_controller.dart | 27 ++++++++++++- lib/main.dart | 2 +- lib/service/auth_service.dart | 2 + lib/utils/dio_service.dart | 20 ++++++---- lib/utils/user_manager.dart | 18 +++++++++ 7 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 ios/PrivacyInfo.xcprivacy diff --git a/ios/PrivacyInfo.xcprivacy b/ios/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..ecec85d4 --- /dev/null +++ b/ios/PrivacyInfo.xcprivacy @@ -0,0 +1,57 @@ + + + + + + NSPrivacyAccessedAPITypes + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + + NSPrivacyAccessedAPITypeReasons + + CA92.1 + 1C8F.1 + + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + 0A2A.1 + + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryDiskSpace + NSPrivacyAccessedAPITypeReasons + + E174.1 + + + + + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2a285a3e..6c30220b 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 4EB854D129889EE1A9F5CBAF /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239794E191ECC31390795268 /* Pods_Runner.framework */; }; + 6F8097AE2C64F082004A75E9 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 6F8097AD2C64F082004A75E9 /* PrivacyInfo.xcprivacy */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; @@ -51,7 +52,8 @@ 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 411AA052E50F1F579C6A8C98 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 4D03C47278E5B0EB654A3EFA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 6F8097AA2C6398BA004A75E9 /* RunnerRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerRelease.entitlements; sourceTree = ""; }; + 6F8097AD2C64F082004A75E9 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 6F8097AF2C64F495004A75E9 /* RunnerRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerRelease.entitlements; sourceTree = ""; }; 6FCD42AC2C266AE00030334E /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -113,6 +115,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + 6F8097AD2C64F082004A75E9 /* PrivacyInfo.xcprivacy */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, @@ -135,7 +138,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( - 6F8097AA2C6398BA004A75E9 /* RunnerRelease.entitlements */, + 6F8097AF2C64F495004A75E9 /* RunnerRelease.entitlements */, 6FCD42AC2C266AE00030334E /* Runner.entitlements */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, diff --git a/lib/controllers/map_controller.dart b/lib/controllers/map_controller.dart index a0558b8c..0363ee00 100644 --- a/lib/controllers/map_controller.dart +++ b/lib/controllers/map_controller.dart @@ -11,11 +11,13 @@ import '../constants/app_colors.dart'; import '../enums/pixel_mode.dart'; import '../models/individual_history_pixel.dart'; import '../models/individual_mode_pixel.dart'; +import '../models/pixel_occupy_request.dart'; import '../models/user_pixel_count.dart'; import '../service/location_service.dart'; import '../service/pixel_service.dart'; import '../service/user_service.dart'; import '../utils/date_handler.dart'; +import '../utils/dio_service.dart'; import '../utils/user_manager.dart'; import '../widgets/map/filter_bottom_sheet.dart'; import '../widgets/pixel.dart'; @@ -150,7 +152,15 @@ class MapController extends SuperController { void _trackUserLocation() { _locationService.location.onLocationChanged.listen((newLocation) async { _locationService.currentLocation = newLocation; - + print("-----------------------track-------------------"); + // DioService().getDio().get("/trackTest"); + PixelOccupyRequest pixelRequest = PixelOccupyRequest( + userId: 20, + x: 200, + y: 200, + communityId: null, + ); + await DioService().getDio().post('/pixels', data: pixelRequest.toJson()); if (isCameraTrackingUser.value) { setCameraOnCurrentLocation(); } @@ -226,8 +236,21 @@ class MapController extends SuperController { } void trackPixels() { - _updatePixelTimer = Timer.periodic(const Duration(seconds: 10), (timer) async { + _updatePixelTimer = + Timer.periodic(const Duration(seconds: 10), (timer) async { updatePixels(); + // try { + // DioService().getDio().get("/periodTest"); + // } catch (e) {} + + PixelOccupyRequest pixelRequest = PixelOccupyRequest( + userId: 20, + x: 100, + y: 100, + communityId: null, + ); + await DioService().getDio().post('/pixels', data: pixelRequest.toJson()); + print("update pixel!!"); var tmp = await Location().getLocation(); print("${DateTime.now()}"); diff --git a/lib/main.dart b/lib/main.dart index 49d180c8..d73301b5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; +import 'package:ground_flip/service/location_service.dart'; import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart'; import 'package:kakao_flutter_sdk/kakao_flutter_sdk_common.dart'; @@ -19,7 +20,6 @@ import 'screens/policy_screen.dart'; import 'screens/setting_screen.dart'; import 'screens/sign_up_screen.dart'; import 'service/auth_service.dart'; -import 'service/location_service.dart'; import 'utils/user_manager.dart'; import 'widgets/common/internet_disconnect.dart'; diff --git a/lib/service/auth_service.dart b/lib/service/auth_service.dart index 0238fd88..64afb041 100644 --- a/lib/service/auth_service.dart +++ b/lib/service/auth_service.dart @@ -55,6 +55,8 @@ class AuthService { return false; } else { UserManager().setUserId(extractUserIdFromToken(accessToken)); + UserManager().setAccessToken(accessToken); + UserManager().setRefreshToken(refreshToken); return true; } } diff --git a/lib/utils/dio_service.dart b/lib/utils/dio_service.dart index 2d471f37..e2e90248 100644 --- a/lib/utils/dio_service.dart +++ b/lib/utils/dio_service.dart @@ -4,15 +4,17 @@ import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get/get.dart' hide Response; +import 'package:ground_flip/utils/user_manager.dart'; import '../models/reissue_response.dart'; import '../service/auth_service.dart'; -import 'secure_storage.dart'; class DioService { static final DioService _dioServices = DioService._internal(); static final String baseUrl = dotenv.env['BASE_URL']!; - final SecureStorage secureStorage = SecureStorage(); + + // final SecureStorage secureStorage = SecureStorage(); + final UserManager userManager = UserManager(); factory DioService() => _dioServices; @@ -29,7 +31,8 @@ class DioService { _dio.interceptors.add( InterceptorsWrapper( onRequest: (options, handler) async { - final accessToken = await secureStorage.readAccessToken(); + // final accessToken = await secureStorage.readAccessToken(); + final accessToken = userManager.getAccessToken(); options.headers.addAll({ 'Authorization': 'Bearer $accessToken', }); @@ -47,9 +50,11 @@ class DioService { if (dioException.response?.statusCode == HttpStatus.unauthorized) { try { ReissueResponse reissueResponse = await reissueToken(); - await secureStorage.writeAccessToken(reissueResponse.accessToken); - await secureStorage - .writeRefreshToken(reissueResponse.refreshToken); + userManager.setAccessToken(reissueResponse.accessToken!); + userManager.setRefreshToken(reissueResponse.refreshToken!); + // await secureStorage.writeAccessToken(reissueResponse.accessToken); + // await secureStorage + // .writeRefreshToken(reissueResponse.refreshToken); Response resendResponse = await resendRequest(dioException, reissueResponse); @@ -82,7 +87,8 @@ class DioService { } Future reissueToken() async { - final refreshToken = await secureStorage.readRefreshToken(); + // final refreshToken = await secureStorage.readRefreshToken(); + final refreshToken = userManager.getRefreshToken(); final dio = Dio(); var response = await dio .post("$baseUrl/auth/reissue", data: {"refreshToken": refreshToken}); diff --git a/lib/utils/user_manager.dart b/lib/utils/user_manager.dart index ab26a652..4b7706e0 100644 --- a/lib/utils/user_manager.dart +++ b/lib/utils/user_manager.dart @@ -8,6 +8,8 @@ class UserManager { UserManager._internal(); int? userId; + String? accessToken; + String? refreshToken; void init() { userId = null; @@ -17,7 +19,23 @@ class UserManager { userId = id; } + void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + int? getUserId() { return userId; } + + String getAccessToken() { + return accessToken!; + } + + String getRefreshToken() { + return refreshToken!; + } } From d7bfbbd49fdbe9780d28c784cab6925451c8750b Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 8 Aug 2024 23:26:31 +0900 Subject: [PATCH 3/6] =?UTF-8?q?M3-237=20Feat=20:=20UserManager=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/service/auth_service.dart | 2 ++ lib/utils/user_manager.dart | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/service/auth_service.dart b/lib/service/auth_service.dart index 64afb041..b4254e9f 100644 --- a/lib/service/auth_service.dart +++ b/lib/service/auth_service.dart @@ -85,6 +85,8 @@ class AuthService { await secureStorage.writeAccessToken(authResponse.accessToken); await secureStorage.writeRefreshToken(authResponse.refreshToken); UserManager().setUserId(extractUserIdFromToken(authResponse.accessToken!)); + UserManager().setAccessToken(authResponse.accessToken!); + UserManager().setRefreshToken(authResponse.refreshToken!); } Future postKakaoLogin(String accessToken) async { diff --git a/lib/utils/user_manager.dart b/lib/utils/user_manager.dart index 4b7706e0..eb64eb26 100644 --- a/lib/utils/user_manager.dart +++ b/lib/utils/user_manager.dart @@ -13,6 +13,8 @@ class UserManager { void init() { userId = null; + accessToken = null; + refreshToken = null; } void setUserId(int id) { @@ -32,10 +34,10 @@ class UserManager { } String getAccessToken() { - return accessToken!; + return accessToken ?? "token"; } String getRefreshToken() { - return refreshToken!; + return refreshToken ?? "token"; } } From 7e973842fe2c57ab619d7e932fe84665870690c6 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 8 Aug 2024 23:37:40 +0900 Subject: [PATCH 4/6] =?UTF-8?q?M3-500=20Feat=20:=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=9A=A9=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/controllers/map_controller.dart | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/lib/controllers/map_controller.dart b/lib/controllers/map_controller.dart index 0363ee00..700f87fa 100644 --- a/lib/controllers/map_controller.dart +++ b/lib/controllers/map_controller.dart @@ -4,20 +4,17 @@ import 'dart:math' as math; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:location/location.dart'; import 'package:wakelock_plus/wakelock_plus.dart'; import '../constants/app_colors.dart'; import '../enums/pixel_mode.dart'; import '../models/individual_history_pixel.dart'; import '../models/individual_mode_pixel.dart'; -import '../models/pixel_occupy_request.dart'; import '../models/user_pixel_count.dart'; import '../service/location_service.dart'; import '../service/pixel_service.dart'; import '../service/user_service.dart'; import '../utils/date_handler.dart'; -import '../utils/dio_service.dart'; import '../utils/user_manager.dart'; import '../widgets/map/filter_bottom_sheet.dart'; import '../widgets/pixel.dart'; @@ -152,15 +149,6 @@ class MapController extends SuperController { void _trackUserLocation() { _locationService.location.onLocationChanged.listen((newLocation) async { _locationService.currentLocation = newLocation; - print("-----------------------track-------------------"); - // DioService().getDio().get("/trackTest"); - PixelOccupyRequest pixelRequest = PixelOccupyRequest( - userId: 20, - x: 200, - y: 200, - communityId: null, - ); - await DioService().getDio().post('/pixels', data: pixelRequest.toJson()); if (isCameraTrackingUser.value) { setCameraOnCurrentLocation(); } @@ -239,22 +227,6 @@ class MapController extends SuperController { _updatePixelTimer = Timer.periodic(const Duration(seconds: 10), (timer) async { updatePixels(); - // try { - // DioService().getDio().get("/periodTest"); - // } catch (e) {} - - PixelOccupyRequest pixelRequest = PixelOccupyRequest( - userId: 20, - x: 100, - y: 100, - communityId: null, - ); - await DioService().getDio().post('/pixels', data: pixelRequest.toJson()); - - print("update pixel!!"); - var tmp = await Location().getLocation(); - print("${DateTime.now()}"); - print('${tmp.longitude} ${tmp.latitude}'); }); } From 56c036c8241757f3aeb11e5aca36e0f6db65c22a Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 8 Aug 2024 23:52:40 +0900 Subject: [PATCH 5/6] =?UTF-8?q?M3-500=20Feat=20:=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=EC=9D=B4=20=EC=9E=AC=EB=B0=9C=EA=B8=89=EB=90=98=EB=A9=B4=20sec?= =?UTF-8?q?ure=20storage=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/controllers/map_controller.dart | 1 + lib/main.dart | 2 +- lib/utils/dio_service.dart | 9 ++------- lib/utils/user_manager.dart | 16 ++++++++++++++++ 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6c30220b..0b31af42 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -502,7 +502,7 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 3BD2BV9TRM; ENABLE_BITCODE = NO; - FLUTTER_BUILD_NAME = 1.0.3; + FLUTTER_BUILD_NAME = 1.0.4; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ground Flip"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.healthcare-fitness"; @@ -511,7 +511,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.3; + MARKETING_VERSION = 1.0.4; PRODUCT_BUNDLE_IDENTIFIER = com.m3pro.groundFlip; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -692,7 +692,7 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 3BD2BV9TRM; ENABLE_BITCODE = NO; - FLUTTER_BUILD_NAME = 1.0.3; + FLUTTER_BUILD_NAME = 1.0.4; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ground Flip"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.healthcare-fitness"; @@ -701,7 +701,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.3; + MARKETING_VERSION = 1.0.4; PRODUCT_BUNDLE_IDENTIFIER = com.m3pro.groundFlip; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -722,7 +722,7 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 3BD2BV9TRM; ENABLE_BITCODE = NO; - FLUTTER_BUILD_NAME = 1.0.3; + FLUTTER_BUILD_NAME = 1.0.4; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ground Flip"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.healthcare-fitness"; @@ -731,7 +731,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.3; + MARKETING_VERSION = 1.0.4; PRODUCT_BUNDLE_IDENTIFIER = com.m3pro.groundFlip; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/controllers/map_controller.dart b/lib/controllers/map_controller.dart index 700f87fa..3c0e599b 100644 --- a/lib/controllers/map_controller.dart +++ b/lib/controllers/map_controller.dart @@ -226,6 +226,7 @@ class MapController extends SuperController { void trackPixels() { _updatePixelTimer = Timer.periodic(const Duration(seconds: 10), (timer) async { + UserManager().updateSecureStorage(); updatePixels(); }); } diff --git a/lib/main.dart b/lib/main.dart index d73301b5..49d180c8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,7 +7,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; -import 'package:ground_flip/service/location_service.dart'; import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart'; import 'package:kakao_flutter_sdk/kakao_flutter_sdk_common.dart'; @@ -20,6 +19,7 @@ import 'screens/policy_screen.dart'; import 'screens/setting_screen.dart'; import 'screens/sign_up_screen.dart'; import 'service/auth_service.dart'; +import 'service/location_service.dart'; import 'utils/user_manager.dart'; import 'widgets/common/internet_disconnect.dart'; diff --git a/lib/utils/dio_service.dart b/lib/utils/dio_service.dart index e2e90248..3f2881ca 100644 --- a/lib/utils/dio_service.dart +++ b/lib/utils/dio_service.dart @@ -4,16 +4,15 @@ import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get/get.dart' hide Response; -import 'package:ground_flip/utils/user_manager.dart'; import '../models/reissue_response.dart'; import '../service/auth_service.dart'; +import 'user_manager.dart'; class DioService { static final DioService _dioServices = DioService._internal(); static final String baseUrl = dotenv.env['BASE_URL']!; - // final SecureStorage secureStorage = SecureStorage(); final UserManager userManager = UserManager(); factory DioService() => _dioServices; @@ -31,7 +30,6 @@ class DioService { _dio.interceptors.add( InterceptorsWrapper( onRequest: (options, handler) async { - // final accessToken = await secureStorage.readAccessToken(); final accessToken = userManager.getAccessToken(); options.headers.addAll({ 'Authorization': 'Bearer $accessToken', @@ -52,9 +50,6 @@ class DioService { ReissueResponse reissueResponse = await reissueToken(); userManager.setAccessToken(reissueResponse.accessToken!); userManager.setRefreshToken(reissueResponse.refreshToken!); - // await secureStorage.writeAccessToken(reissueResponse.accessToken); - // await secureStorage - // .writeRefreshToken(reissueResponse.refreshToken); Response resendResponse = await resendRequest(dioException, reissueResponse); @@ -87,13 +82,13 @@ class DioService { } Future reissueToken() async { - // final refreshToken = await secureStorage.readRefreshToken(); final refreshToken = userManager.getRefreshToken(); final dio = Dio(); var response = await dio .post("$baseUrl/auth/reissue", data: {"refreshToken": refreshToken}); ReissueResponse reissueResponse = ReissueResponse.fromJson(response.data["data"]); + UserManager().setTokenReissued(); return reissueResponse; } diff --git a/lib/utils/user_manager.dart b/lib/utils/user_manager.dart index eb64eb26..84926241 100644 --- a/lib/utils/user_manager.dart +++ b/lib/utils/user_manager.dart @@ -1,5 +1,8 @@ +import 'secure_storage.dart'; + class UserManager { static final UserManager _instance = UserManager._internal(); + final SecureStorage secureStorage = SecureStorage(); factory UserManager() { return _instance; @@ -10,11 +13,20 @@ class UserManager { int? userId; String? accessToken; String? refreshToken; + bool? isTokenReissued; void init() { userId = null; accessToken = null; refreshToken = null; + isTokenReissued = null; + } + + updateSecureStorage() { + if (isTokenReissued == true) { + secureStorage.writeAccessToken(accessToken); + secureStorage.writeRefreshToken(refreshToken); + } } void setUserId(int id) { @@ -29,6 +41,10 @@ class UserManager { this.refreshToken = refreshToken; } + void setTokenReissued() { + isTokenReissued = true; + } + int? getUserId() { return userId; } From 2e4494b413f7e8fb13f6dc6cfafe089d084a8bea Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 8 Aug 2024 23:58:57 +0900 Subject: [PATCH 6/6] =?UTF-8?q?M3-237=20Chore=20:=20iOS=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 6ce5b0b2..8e3ca5df 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -51,7 +51,7 @@