Skip to content

Commit

Permalink
Merge pull request #81 from sparcs-kaist/#80-bug-fix-change-backend-a…
Browse files Browse the repository at this point in the history
…ddress-and-error-code

Refactor: Change Cookie URL
  • Loading branch information
happycastle114 authored Sep 18, 2023
2 parents 0ebe5ff + cf86d03 commit 9fc43ee
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<array>
<string>itms-beta</string>
<string>itms</string>
<string>supertoss</string>
<string>uber</string>
<string>tmoneyonda</string>
<string>kakaotalk</string>
<string>kakaot</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
Expand Down
36 changes: 26 additions & 10 deletions lib/views/taxiView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ class TaxiView extends HookWidget {
if (Token().accessToken != '') {
await Token().deleteAll();
}
_cookieManager.deleteAllCookies();
await _cookieManager.deleteCookie(
url: Uri.parse(RemoteConfigController().backUrl),
name: "connect.sid");
isAuthLogin.value = false;
isLogin.value = false;
isFirstLogin.value = false;
Expand Down Expand Up @@ -300,9 +302,15 @@ class TaxiView extends HookWidget {
shouldOverrideUrlLoading: (controller, navigationAction) async {
var newHeaders = Map<String, String>.from(
navigationAction.request.headers ?? {});
if (!newHeaders.containsKey("Referer") &&
if (Platform.isAndroid &&
!newHeaders.containsKey("Referer") &&
navigationAction.request.url.toString() !=
'about:blank') {
'about:blank' &&
(navigationAction.request.url?.origin ==
Uri.parse(address).origin ||
navigationAction.request.url?.origin ==
Uri.parse(RemoteConfigController().backUrl)
.origin)) {
newHeaders['Referer'] =
navigationAction.request.url.toString();
newHeaders['Origin'] = RemoteConfigController().frontUrl;
Expand Down Expand Up @@ -350,11 +358,14 @@ class TaxiView extends HookWidget {
await FcmToken()
.removeToken(Token().getAccessToken());
await Token().deleteAll();
await _cookieManager.deleteAllCookies();
isLogin.value = false;
isAuthLogin.value = false;
await _cookieManager.deleteAllCookies();
await _controller.value!.loadUrl(
urlRequest: URLRequest(url: Uri.parse(address)));
await _controller.value?.loadUrl(
urlRequest: URLRequest(
url: Uri.parse(RemoteConfigController()
.frontUrl
.toString())));
} catch (e) {
// TODO
Fluttertoast.showToast(
Expand Down Expand Up @@ -396,15 +407,18 @@ class TaxiView extends HookWidget {
sessionToken.value != '' &&
uri?.origin == Uri.parse(address).origin &&
(await _cookieManager.getCookie(
url: Uri.parse(address), name: "connect.sid"))
url: Uri.parse(
RemoteConfigController().backUrl),
name: "connect.sid"))
?.value !=
sessionToken.value) {
try {
await _controller.value?.stopLoading();
await _cookieManager.deleteCookie(
url: Uri.parse(address), name: "connect.sid");
url: Uri.parse(RemoteConfigController().backUrl),
name: "connect.sid");
await _cookieManager.setCookie(
url: Uri.parse(address),
url: Uri.parse(RemoteConfigController().backUrl),
name: "connect.sid",
value: sessionToken.value,
);
Expand Down Expand Up @@ -492,7 +506,9 @@ class TaxiView extends HookWidget {
// 될 때까지 리로드
if (!isLoaded.value && LoadCount.value < 10) {
LoadCount.value++;
} else if (isServerError.value == false && code != 102) {
} else if (isServerError.value == false &&
code != 102 &&
code != -999) {
Fluttertoast.showToast(
msg: "서버와의 연결에 실패했습니다.",
toastLength: Toast.LENGTH_SHORT,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.3+26
version: 1.0.4+29

environment:
sdk: ">=2.17.5 <3.0.0"
Expand Down

0 comments on commit 9fc43ee

Please sign in to comment.