Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c45e40

Browse files
authored
fix: leetcode-cn can not use GitHub log in bug (leetcode-tools#46)
1 parent404420e commit1c45e40

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎lib/plugins/leetcode.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,16 @@ plugin.login = function(user, cb) {
540540
};
541541

542542
functionparseCookie(cookie,body,cb){
543+
constisCN=config.app==='leetcode.cn';
543544
constSessionPattern=/LEETCODE_SESSION=(.+?)(;|$)/;
544-
constcsrfPattern=/csrftoken=(.+?)(;|$)/;
545+
letcsrfPattern;
546+
if(isCN){
547+
csrfPattern=/name="csrfmiddlewaretoken"value="(.*?)"/;
548+
}else{
549+
csrfPattern=/csrftoken=(.+?)(;|$)/;
550+
}
551+
constreCsrfResult=csrfPattern.exec(isCN?body:cookie);
545552
constreSessionResult=SessionPattern.exec(cookie);
546-
constreCsrfResult=csrfPattern.exec(cookie);
547553
if(reSessionResult===null||reCsrfResult===null){
548554
returncb('invalid cookie?');
549555
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp