@@ -8,9 +8,10 @@ var h = require('./helper');
88
99// update options with user credentials
1010function signOpts ( opts , user ) {
11- opts . headers . Cookie = 'PHPSESSID =' + user . sessionId +
11+ opts . headers . Cookie = 'LEETCODE_SESSION =' + user . sessionId +
1212 ';csrftoken=' + user . sessionCSRF + ';' ;
1313 opts . headers [ 'X-CSRFToken' ] = user . sessionCSRF ;
14+ opts . headers [ 'X-Requested-With' ] = 'XMLHttpRequest' ;
1415}
1516
1617function makeOpts ( url ) {
@@ -216,7 +217,7 @@ leetcodeClient.login = function(user, cb) {
216217 if ( e ) return cb ( e ) ;
217218
218219 user . sessionCSRF = h . getSetCookieValue ( resp , 'csrftoken' ) ;
219- user . sessionId = h . getSetCookieValue ( resp , 'PHPSESSID ' ) ;
220+ user . sessionId = h . getSetCookieValue ( resp , 'LEETCODE_SESSION ' ) ;
220221 user . name = h . getSetCookieValue ( resp , 'messages' )
221222 . match ( 'Successfully signed in as ([^.]*)' ) [ 1 ] ;
222223
@@ -251,7 +252,6 @@ function runCode(opts, problem, cb) {
251252 opts . method = 'POST' ;
252253 opts . headers . Origin = config . URL_BASE ;
253254 opts . headers . Referer = problem . link ;
254- opts . headers [ 'X-Requested-With' ] = 'XMLHttpRequest' ;
255255 opts . json = true ;
256256 opts . _delay = opts . _delay || 1 ; // in seconds
257257
@@ -323,7 +323,6 @@ leetcodeClient.starProblem = function(problem, starred, cb) {
323323 opts . method = ( starred ? 'POST' : 'DELETE' ) ;
324324 opts . headers . Origin = config . URL_BASE ;
325325 opts . headers . Referer = problem . link ;
326- opts . headers [ 'X-Requested-With' ] = 'XMLHttpRequest' ;
327326 opts . json = true ;
328327 opts . body = { 'qid' : problem . id } ;
329328
0 commit comments