Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Change Cookie URL #81

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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