Skip to content

Commit 6cd1d9d

Browse files
committed
fix: Adapt to new interface of nju authserver
1 parent d246580 commit 6cd1d9d

6 files changed

Lines changed: 13 additions & 16 deletions

File tree

Dioxus.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# HTML title tag content
66
title = "南哪另一课表"
77

8-
base_path="schedule2/"
98

109
# include `assets` in web platform
1110
[web.resource]

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@
2323
<img width="935" height="768" alt="Select school page" src="https://github.com/user-attachments/assets/7eae85d8-e493-46cb-ab48-f452aaae1c93" />
2424
<img width="935" height="768" alt="Login page" src="https://github.com/user-attachments/assets/6fe5bfae-2aa7-4231-8894-389d73e0705f" />
2525

26-
27-
28-
2926
## 使用提供的服务器
3027

3128
[新版](https://n100.tail32664.ts.net/schedule-new/)
3229

3330
[旧版](https://n100.tail32664.ts.net/schedule/)
3431

35-
3632
## 隐私与数据安全
3733

3834
此项目用于搭建一个服务器(以下称为“本服务器"),该服务器会将南大的课程表转换为iCalendar日历格式。为了从南大的服务器获取课程表,本服务器需要拿到你的统一认证用户名和密码以登陆。
@@ -86,8 +82,8 @@ db_path="./cookies.sqlite"
8682
# Must start with https://
8783
site_url="https://example.com/sub_dir"
8884
```
89-
</details>
9085

86+
</details>
9187

9288
<details>
9389
<summary>参与开发</summary>
@@ -163,7 +159,6 @@ dx serve --hot-reload true
163159

164160
如果要适配新学校,改第一部份就可以了。如果有问题欢迎提issue/discussion或者加QQ群讨论。
165161

166-
167-
168162
更多内容可见注释,也欢迎GitHub Discussion/QQ群直接问~
163+
169164
</details>

src/adapters/nju_undergrad/login.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use sqlx::prelude::FromRow;
2121
use std::sync::Arc;
2222
use std::{collections::HashMap, io::Cursor};
2323
use tokio::sync::Mutex;
24-
use tracing::info;
24+
use tracing::{debug, info};
2525
use uuid::Uuid;
2626
// use xee_xpath::{DocumentHandle, Documents, Queries, Query};
2727

@@ -107,7 +107,7 @@ impl LoginSession for Session {
107107
let encrypted_password = encrypt(
108108
&password,
109109
self.context
110-
.get("pwdDefaultEncryptSalt")
110+
.get("pwdEncryptSalt")
111111
.ok_or(anyhow!("Failed to find password encryption salt"))?,
112112
);
113113

@@ -180,15 +180,17 @@ impl Session {
180180
/// by requesting the login page
181181
pub async fn new(db: Arc<Mutex<SqlitePool>>) -> Result<Self> {
182182
let (client, _jar) = build_client().await?;
183+
debug!("Requesting login page");
183184
let login_page_response = client
184185
.get("https://authserver.nju.edu.cn/authserver/login")
185186
.send()
186187
.await?;
187188

188189
let context = extract_context(login_page_response.text().await?.xptree()?)?;
189190

191+
debug!("Requesting captcha");
190192
let captcha_content = client
191-
.get("https://authserver.nju.edu.cn/authserver/captcha.html")
193+
.get("https://authserver.nju.edu.cn/authserver/getCaptcha.htl")
192194
.send()
193195
.await?
194196
.bytes()
@@ -209,7 +211,7 @@ impl Session {
209211

210212
/// Extract some attributes on the page needed for POST requests.
211213
pub fn extract_context(login_page: XpathItemTree) -> Result<HashMap<String, String>> {
212-
let variables = login_page.xpath("//form[@id='casLoginForm']/input")?;
214+
let variables = login_page.xpath("//form[@id='pwdFromId']/input")?;
213215

214216
let mut context = HashMap::new();
215217

@@ -222,6 +224,7 @@ pub fn extract_context(login_page: XpathItemTree) -> Result<HashMap<String, Stri
222224
) else {
223225
continue;
224226
};
227+
debug!("Context: adding name={}, value={}", name, value);
225228
context.insert(name.to_string(), value.to_string());
226229
}
227230

src/gui/steps/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn Login() -> Element {
1919

2020
rsx! {
2121
Hero {
22-
image: "https://authserver.nju.edu.cn/authserver/custom/images/back3.jpg",
22+
image: "https://authserver.nju.edu.cn/authserver/njuTheme/customStatic/web/images/back3.jpg",
2323

2424
FieldSet {
2525
onsubmit: move |event| {

src/gui/steps/select_school.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn SchoolAPISelect() -> Element {
1414

1515
rsx! {
1616
Hero {
17-
image: "https://authserver.nju.edu.cn/authserver/custom/images/back3.jpg",
17+
image: "https://authserver.nju.edu.cn/authserver/njuTheme/customStatic/web/images/back3.jpg",
1818

1919
h1 {
2020
class: "mb-5 text-5xl font-bold text-neutral-content",

src/gui/steps/view_link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pub fn ViewLink() -> Element {
1919

2020
rsx! {
2121
Hero {
22-
image: "https://authserver.nju.edu.cn/authserver/custom/images/back3.jpg",
22+
image: "https://authserver.nju.edu.cn/authserver/njuTheme/customStatic/web/images/back3.jpg",
2323

2424
div {
25-
class: "card bg-base-200 max-w-96 card-xl shadow-sm",
25+
class: "card bg-base-200 max-w-lg card-xl shadow-sm",
2626

2727
div {
2828
class: "card-body",

0 commit comments

Comments
 (0)