Skip to content

Commit 56e5869

Browse files
committed
fix: 修正懒得修改密码导致的一系列错误
1 parent 57baedf commit 56e5869

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/src/main/java/team/bjtuss/bjtuselfservice/StudentAccountManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public CompletableFuture<Boolean> init(String stuId, String password) {
137137
if (isLogin) {
138138
return CompletableFuture.completedFuture(true);
139139
} else {
140-
return attemptLoginWithRetry(stuId, password, 5);
140+
return attemptLoginWithRetry(stuId, password, 3);
141141
}
142142
});
143143
}

app/src/main/java/team/bjtuss/bjtuselfservice/web/MisDataManager.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ public void onFailure(Call call, IOException e) {
5858
@Override
5959
public void onResponse(Call call, Response response) throws IOException {
6060
String url = response.request().url().toString();
61+
if ("https://mis.bjtu.edu.cn/home/".equals(url)) {
62+
String body = response.body().string();
63+
Document doc = Jsoup.parse(body);
64+
Element name = doc.selectFirst(".name_right > h3 > a");
65+
if (name == null) {
66+
loginCallback.onFailure(1);
67+
return;
68+
}
69+
String nameStr = name.text().split(",")[0];
70+
Element id = doc.selectFirst(".name_right .nr_con span:contains(身份)");
71+
String idStr = id.text().replace("身份:", "");
72+
Element department = doc.selectFirst(".name_right .nr_con span:contains(部门)");
73+
String departmentStr = department.text().replace("部门:", "");
74+
loginCallback.onResponse(nameStr + ";" + idStr + ";" + departmentStr);
75+
return;
76+
}
6177
Request ttRequest = new Request.Builder()
6278
.url(url)
6379
.header("Host", "cas.bjtu.edu.cn")
@@ -157,7 +173,7 @@ public void onResponse(Call call, Response response) throws IOException {
157173
String departmentStr = department.text().replace("部门:", "");
158174
loginCallback.onResponse(nameStr + ";" + idStr + ";" + departmentStr);
159175
} else {
160-
loginCallback.onFailure(1);
176+
loginCallback.onFailure(0);
161177
}
162178
} finally {
163179
response.close();

0 commit comments

Comments
 (0)