Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

add leetcode user -c that user can login with cookie #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 2, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change regex bug
  • Loading branch information
yihong0618 committed Nov 29, 2019
commit 6f2b68f0d3aef5e6ddbeafa08a000087ec522c1a
6 changes: 4 additions & 2 deletions lib/plugins/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,17 @@ plugin.login = function(user, cb) {

plugin.cookieLogin = function(user, cb) {
// re pattern for cookie chrome or firefox
const SessionPattern = /LEETCODE_SESSION=(.*);?$/im;
const csrfPattern = /csrftoken=(.*);?$/im;
const SessionPattern = /LEETCODE_SESSION=(.+?)(;|$)/;
const csrfPattern = /csrftoken=(.+?)(;|$)/;
const reSessionResult = SessionPattern.exec(user.cookie);
const reCsrfResult = csrfPattern.exec(user.cookie);
console.log(reCsrfResult);
if (reSessionResult === null || reCsrfResult === null) {
return cb('invalid cookie?')
}
user.sessionId = reSessionResult[1];
user.sessionCSRF = reCsrfResult[1];
console.log(user.sessionCSRF);
session.saveUser(user);
plugin.getUser(user, cb);
}
Expand Down