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

Update ischool login method with retry mechanism #225

Merged
merged 25 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fbed2e9
iSchool login method change
umeow0716 Jan 26, 2024
8b349f7
add ischool login test
James-Lu-none Jan 27, 2024
286fc4b
remove outdated I-School retry loop
James-Lu-none Jan 27, 2024
ee19b64
add session out_of_date error
James-Lu-none Jan 27, 2024
7bb6ad2
add retry mechanis, for getLoginOAuth
James-Lu-none Jan 27, 2024
3bb8c48
remove unused import from test
James-Lu-none Feb 16, 2024
d88ff18
remove unused parameter
James-Lu-none Feb 16, 2024
ddcd27c
rewrite login methods
James-Lu-none Feb 16, 2024
d5fb896
add getSSOIndexResponse function
James-Lu-none Feb 16, 2024
ec437bc
remove unnecessary redirection
James-Lu-none Feb 16, 2024
e5c566a
update comments
James-Lu-none Feb 16, 2024
4c02ed7
dart format
James-Lu-none Feb 16, 2024
7c2b99a
add retry mechanism in oauth server request
James-Lu-none Feb 16, 2024
93c7956
update comments
James-Lu-none Feb 16, 2024
a790a9c
refactoring the retry logic
James-Lu-none Feb 18, 2024
68c30d3
making logEventToFirebase optional
James-Lu-none Feb 18, 2024
6de2398
convert to named argument
James-Lu-none Feb 18, 2024
ff2f9bc
remove unnecessary else statement
James-Lu-none Feb 18, 2024
f69f2c3
rewrite login retry mechanism on step 2
James-Lu-none Feb 18, 2024
aa3b705
add log
James-Lu-none Feb 18, 2024
a2aa391
extend ischool connection state
James-Lu-none Feb 21, 2024
6ba6660
add error handling
James-Lu-none Feb 21, 2024
6aa53b5
update comment
James-Lu-none Feb 21, 2024
bf23aa0
dart format
James-Lu-none Feb 21, 2024
23ff926
Merge branch 'master' into update_ischool_login_method_with_retry
James-Lu-none Feb 28, 2024
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
Prev Previous commit
Merge branch 'master' into update_ischool_login_method_with_retry
James-Lu-none authored Feb 28, 2024
commit 23ff9263485c74927c06b09c6e985b6d8b39d94b
47 changes: 47 additions & 0 deletions lib/src/connector/ischool_plus_connector.dart
Original file line number Diff line number Diff line change
@@ -108,6 +108,53 @@ class ISchoolPlusConnector {
return "";
}

static Future<ReturnWithStatus<List<CourseStudent>>> getCourseStudent(String courseId) async {
try {
if (!await _selectCourse(courseId)) {
final returnResult = ReturnWithStatus<List<CourseStudent>>();
returnResult.status = IPlusReturnStatus.noPermission;
return returnResult;
}

ConnectorParameter parameter = ConnectorParameter(_getCourseStudentList);
String result = await Connector.getDataByGet(parameter);

html.Document tagNode = html.parse(result);
html.Element table = tagNode.querySelectorAll('table')[1];
List<html.Element> nodes = table.querySelectorAll('tr');

List<CourseStudent> courseStudents = <CourseStudent>[];
for (int i = 0; i < nodes.length; i++) {
html.Element node = nodes[i].querySelectorAll('td')[1];

String information = node.querySelector('div').innerHtml;
int splitIndex = information.indexOf(' ');

String studentId = information.substring(0, splitIndex);
String studentName = information.substring(splitIndex + 2, information.length - 1);

// 過濾掉校務人士,如有多身分考慮枚舉或過濾 Email
if (studentId == 'istudyoaa') {
continue;
}

CourseStudent courseStudent = CourseStudent(department: "", id: studentId, name: studentName);
courseStudents.add(courseStudent);
}
courseStudents.sort((a, b) => a.id.compareTo(b.id));

final returnResult = ReturnWithStatus<List<CourseStudent>>();
returnResult.status = IPlusReturnStatus.success;
returnResult.result = courseStudents;
return returnResult;
} catch (e, stack) {
Log.eWithStack(e, stack);
final returnResult = ReturnWithStatus<List<CourseStudent>>();
returnResult.status = IPlusReturnStatus.fail;
return returnResult;
}
}

static Future<ReturnWithStatus<List<CourseFileJson>>> getCourseFile(String courseId) async {
ConnectorParameter parameter;
String result;
You are viewing a condensed version of this merge commit. You can view the full changes here.