Skip to content

Commit 158ef8e

Browse files
Merge pull request #218 from sparcs-kaist/217-bug-로그인-무한로딩-문제
Update Version 2.5.2 & Add Reenter Login Page When Error Occurs
2 parents cd81509 + fba4e3f commit 158ef8e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/pages/login_page.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@ class _LoginPageState extends State<LoginPage> {
5656
});
5757
}
5858
},
59-
onPageFinished: (url) {
59+
onPageFinished: (url) async {
6060
String authority = Uri.parse(url).authority;
6161
if (authority == AUTHORITY) {
62-
context.read<AuthModel>().authenticate('https://$AUTHORITY');
62+
try {
63+
context.read<AuthModel>().authenticate('https://$AUTHORITY');
64+
} catch (e) {
65+
setState(() {
66+
_isVisible = true;
67+
});
68+
await controller
69+
.loadRequest(Uri.https(AUTHORITY, '/session/login/', query));
70+
}
6371
} else if (authority == 'sparcssso.kaist.ac.kr') {
6472
setState(() {
6573
_isVisible = true;

lib/providers/auth_model.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ class AuthModel extends ChangeNotifier {
77
bool get isLogined => _isLogined;
88

99
Future<void> authenticate(String url) async {
10+
final cookieManager = WebviewCookieManager();
1011
try {
11-
final cookieManager = WebviewCookieManager();
1212
final cookies = await cookieManager.getCookies(url);
1313
DioProvider().authenticate(cookies);
1414
_isLogined = true;
1515
notifyListeners();
1616
} catch (exception) {
1717
print(exception);
18+
await cookieManager.clearCookies();
19+
throw exception;
1820
}
1921
}
2022

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: Online Timeplanner with Lectures Plus App @ KAIST
1111
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14-
version: 2.5.1+21
14+
version: 2.5.2+22
1515

1616
environment:
1717
sdk: ">=3.2.0 <4.0.0"

0 commit comments

Comments
 (0)