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

Commit 982e743

Browse files
committed
fix: LinkedIn change login way bug
1 parent 4a27102 commit 982e743

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

lib/config.js

Lines changed: 2 additions & 2 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/',

lib/plugins/leetcode.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ function parseCookie(cookie, body, cb) {
563563
function requestLeetcodeAndSave(request, leetcodeUrl, user, cb) {
564564
request.get({url: leetcodeUrl}, function(e, resp, body) {
565565
const redirectUri = resp.request.uri.href;
566+
console.log(redirectUri);
566567
if (redirectUri !== config.sys.urls.leetcode_redirect) {
567568
return cb('Login failed. Please make sure the credential is correct.');
568569
}
@@ -664,8 +665,12 @@ plugin.linkedinLogin = function(user, cb) {
664665
if ( resp.statusCode !== 200) {
665666
return cb('Get LinkedIn session failed');
666667
}
667-
const authenticityToken = body.match(/input name="loginCsrfParam" value="(.*)" /);
668-
if (authenticityToken === null) {
668+
const csrfToken = body.match(/input type="hidden" name="csrfToken" value="(.*?)"/);
669+
const loginCsrfToken = body.match(/input type="hidden" name="loginCsrfParam" value="(.*?)"/);
670+
const sIdString = body.match(/input type="hidden" name="sIdString" value="(.*?)"/);
671+
const pageInstance = body.match(/input type="hidden" name="pageInstance" value="(.*?)"/);
672+
console.log(csrfToken[1], loginCsrfToken[1], sIdString[1], pageInstance[1]);
673+
if (loginCsrfToken === null) {
669674
return cb('Get LinkedIn token failed');
670675
}
671676
const options = {
@@ -676,10 +681,22 @@ plugin.linkedinLogin = function(user, cb) {
676681
},
677682
followAllRedirects: true,
678683
form: {
679-
'session_key': user.login,
680-
'session_password': user.pass,
681-
'loginCsrfParam': authenticityToken[1],
682-
'trk': 'guest_homepage-basic_sign-in-submit'
684+
'csrfToken': csrfToken[1],
685+
'session_key': user.login,
686+
'ac': 2,
687+
'sIdString': sIdString[1],
688+
'parentPageKey': 'd_checkpoint_lg_consumerLogin',
689+
'pageInstance': pageInstance[1],
690+
'trk': 'public_profile_nav-header-signin',
691+
'authUUID': '',
692+
'session_redirect': 'https://www.linkedin.com/feed/',
693+
'loginCsrfParam': loginCsrfToken[1],
694+
'fp_data': 'default',
695+
'_d': 'd',
696+
'showGoogleOneTapLogin': true,
697+
'controlId': 'd_checkpoint_lg_consumerLogin-login_submit_button',
698+
'session_password': user.pass,
699+
'loginFlow': 'REMEMBER_ME_OPTIN'
683700
},
684701
};
685702
_request(options, function(e, resp, body) {

0 commit comments

Comments
 (0)