@@ -21,7 +21,7 @@ use sqlx::prelude::FromRow;
2121use std:: sync:: Arc ;
2222use std:: { collections:: HashMap , io:: Cursor } ;
2323use tokio:: sync:: Mutex ;
24- use tracing:: info;
24+ use tracing:: { debug , info} ;
2525use 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.
211213pub 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
0 commit comments