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

Commit5a23270

Browse files
authored
Fix: LinkedIn login problem. (#43)
* fix: can not download plugins bug* fix: LinkedIn change login way bug* drop: useless console.log, fix: error message* fix: GihHub login for leetcode* bug: fix
1 parent3818bc5 commit5a23270

File tree

2 files changed

+49
-26
lines changed

2 files changed

+49
-26
lines changed

‎lib/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const DEFAULT_CONFIG = {
4747
github_login_request:'https://github.com/login',
4848
github_session_request:'https://github.com/session',
4949
github_tf_session_request:'https://github.com/sessions/two-factor',
50-
linkedin_login_request:'https://www.linkedin.com',
51-
linkedin_session_request:'https://www.linkedin.com/uas/login-submit',
50+
linkedin_login_request:'https://www.linkedin.com/login',
51+
linkedin_session_request:'https://www.linkedin.com/checkpoint/lg/login-submit',
5252
// questions urls
5353
problems:'https://leetcode.com/api/problems/$category/',
5454
problem:'https://leetcode.com/problems/$slug/description/',
@@ -60,7 +60,7 @@ const DEFAULT_CONFIG = {
6060
verify:'https://leetcode.com/submissions/detail/$id/check/',
6161
favorites:'https://leetcode.com/list/api/questions',
6262
favorite_delete:'https://leetcode.com/list/api/questions/$hash/$id',
63-
plugin:'https://raw.githubusercontent.com/leetcode-tools/leetcode-cli-plugins/master/plugins/$name.js'
63+
plugin:'https://raw.githubusercontent.com/leetcode-tools/leetcode-cli/master/lib/plugins/$name.js'
6464
},
6565
},
6666

‎lib/plugins/leetcode.js

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

542542
functionparseCookie(cookie,body,cb){
543-
constisCN=config.app==='leetcode.cn';
544543
constSessionPattern=/LEETCODE_SESSION=(.+?)(;|$)/;
545-
letcsrfPattern;
546-
// leetcode-cn.com Cookie is not the same as leetcode.com in third parties
547-
if(isCN){
548-
csrfPattern=/name="csrfmiddlewaretoken"value="(.*?)"/;
549-
}else{
550-
csrfPattern=/csrftoken=(.+?)(;|$)/;
551-
}
544+
constcsrfPattern=/csrftoken=(.+?)(;|$)/;
552545
constreSessionResult=SessionPattern.exec(cookie);
553-
constreCsrfResult=csrfPattern.exec(isCN?body:cookie);
546+
constreCsrfResult=csrfPattern.exec(cookie);
554547
if(reSessionResult===null||reCsrfResult===null){
555548
returncb('invalid cookie?');
556549
}
@@ -588,9 +581,18 @@ plugin.githubLogin = function(user, cb) {
588581
const_request=request.defaults({jar:true});
589582
_request(urls.github_login_request,function(e,resp,body){
590583
constauthenticityToken=body.match(/name="authenticity_token"value="(.*?)"/);
591-
if(authenticityToken===null){
592-
returncb('Get GitHub token failed');
584+
letgaId=body.match(/name="ga_id"value="(.*?)"/);
585+
if(!gaId){
586+
gaId='';
587+
}
588+
letrequiredField=body.match(/name="required_field_(.*?)"/);
589+
consttimestamp=body.match(/name="timestamp"value="(.*?)"/);
590+
consttimestampSecret=body.match(/name="timestamp_secret"value="(.*?)"/);
591+
592+
if(!(authenticityToken&&timestamp&&timestampSecret&&requiredField)){
593+
returncb('Get GitHub payload failed');
593594
}
595+
requiredField='required_field_'+requiredField[1];
594596
constoptions={
595597
url:urls.github_session_request,
596598
method:'POST',
@@ -599,11 +601,17 @@ plugin.githubLogin = function(user, cb) {
599601
},
600602
followAllRedirects:true,
601603
form:{
602-
'login':user.login,
603-
'password':user.pass,
604-
'authenticity_token':authenticityToken[1],
605-
'utf8':encodeURIComponent('✓'),
606-
'commit':encodeURIComponent('Sign in')
604+
'login':user.login,
605+
'password':user.pass,
606+
'authenticity_token':authenticityToken[1],
607+
'commit':encodeURIComponent('Sign in'),
608+
'ga_id':gaId,
609+
'webauthn-support':'supported',
610+
'webauthn-iuvpaa-support':'unsupported',
611+
'return_to':'',
612+
'requiredField':'',
613+
'timestamp':timestamp[1],
614+
'timestamp_secret':timestampSecret[1],
607615
},
608616
};
609617
_request(options,function(e,resp,body){
@@ -664,9 +672,12 @@ plugin.linkedinLogin = function(user, cb) {
664672
if(resp.statusCode!==200){
665673
returncb('Get LinkedIn session failed');
666674
}
667-
constauthenticityToken=body.match(/inputname="loginCsrfParam"value="(.*)"/);
668-
if(authenticityToken===null){
669-
returncb('Get LinkedIn token failed');
675+
constcsrfToken=body.match(/inputtype="hidden"name="csrfToken"value="(.*?)"/);
676+
constloginCsrfToken=body.match(/inputtype="hidden"name="loginCsrfParam"value="(.*?)"/);
677+
constsIdString=body.match(/inputtype="hidden"name="sIdString"value="(.*?)"/);
678+
constpageInstance=body.match(/inputtype="hidden"name="pageInstance"value="(.*?)"/);
679+
if(!(csrfToken&&loginCsrfToken&&sIdString&&pageInstance)){
680+
returncb('Get LinkedIn payload failed');
670681
}
671682
constoptions={
672683
url:urls.linkedin_session_request,
@@ -676,10 +687,22 @@ plugin.linkedinLogin = function(user, cb) {
676687
},
677688
followAllRedirects:true,
678689
form:{
679-
'session_key':user.login,
680-
'session_password':user.pass,
681-
'loginCsrfParam':authenticityToken[1],
682-
'trk':'guest_homepage-basic_sign-in-submit'
690+
'csrfToken':csrfToken[1],
691+
'session_key':user.login,
692+
'ac':2,
693+
'sIdString':sIdString[1],
694+
'parentPageKey':'d_checkpoint_lg_consumerLogin',
695+
'pageInstance':pageInstance[1],
696+
'trk':'public_profile_nav-header-signin',
697+
'authUUID':'',
698+
'session_redirect':'https://www.linkedin.com/feed/',
699+
'loginCsrfParam':loginCsrfToken[1],
700+
'fp_data':'default',
701+
'_d':'d',
702+
'showGoogleOneTapLogin':true,
703+
'controlId':'d_checkpoint_lg_consumerLogin-login_submit_button',
704+
'session_password':user.pass,
705+
'loginFlow':'REMEMBER_ME_OPTIN'
683706
},
684707
};
685708
_request(options,function(e,resp,body){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp