We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 404420e commit 1c45e40Copy full SHA for 1c45e40
lib/plugins/leetcode.js
@@ -540,10 +540,16 @@ plugin.login = function(user, cb) {
540
};
541
542
function parseCookie(cookie, body, cb) {
543
+ const isCN = config.app === 'leetcode.cn';
544
const SessionPattern = /LEETCODE_SESSION=(.+?)(;|$)/;
- const csrfPattern = /csrftoken=(.+?)(;|$)/;
545
+ let csrfPattern;
546
+ if (isCN) {
547
+ csrfPattern = /name="csrfmiddlewaretoken" value="(.*?)"/;
548
+ } else {
549
+ csrfPattern = /csrftoken=(.+?)(;|$)/;
550
+ }
551
+ const reCsrfResult = csrfPattern.exec(isCN? body: cookie);
552
const reSessionResult = SessionPattern.exec(cookie);
- const reCsrfResult = csrfPattern.exec(cookie);
553
if (reSessionResult === null || reCsrfResult === null) {
554
return cb('invalid cookie?');
555
}
0 commit comments