Skip to content

Commit dd8ba8b

Browse files
authored
fix: can't sign in by cookie on leetcode-cn site (#55)
* fix: can't sign in by cookie on leetcode-cn site * Used const instead of let
1 parent cd5d4ef commit dd8ba8b

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/plugins/leetcode.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,9 @@ plugin.login = function(user, cb) {
534534
};
535535

536536
function parseCookie(cookie, body, cb) {
537-
const isCN = config.app === 'leetcode.cn';
538537
const SessionPattern = /LEETCODE_SESSION=(.+?)(;|$)/;
539-
let csrfPattern;
540-
if (isCN) {
541-
csrfPattern = /name="csrfmiddlewaretoken" value="(.*?)"/;
542-
} else {
543-
csrfPattern = /csrftoken=(.+?)(;|$)/;
544-
}
545-
const reCsrfResult = csrfPattern.exec(isCN? body: cookie);
538+
const csrfPattern = /csrftoken=(.+?)(;|$)/;
539+
const reCsrfResult = csrfPattern.exec(cookie);
546540
const reSessionResult = SessionPattern.exec(cookie);
547541
if (reSessionResult === null || reCsrfResult === null) {
548542
return cb('invalid cookie?');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy