Uh oh!
There was an error while loading. Please reload this page.
solve GitHub login two-factor auth problem and add new node package p… - #35
Conversation
jdneo
left a comment
There was a problem hiding this comment.
I just tried with my GitHub account and it works!!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
@jdneo |
jdneo
commented
Dec 26, 2019
@yihong0618 could you please share more information about the errors you observed from the vs code extension side? Since the third-party login can unblock a lot of users, how about we release a new CLI without the two-factor auth support at first. Then we revisit this issue after that? |
@jdneo |
@jdneo
And no problem for no two-factor I think vscode-leetcode only support GitHub login without two-factor will be good for now. |
jdneo
commented
Dec 27, 2019
I see. I'll release the CLI first to unblock the vscode-leetcode's PR. Just leave this PR here for now until we release the VS Code LeetCode. |
@jdneo |
yihong0618
commented
Dec 27, 2019
@jdneo |
Uh oh!
There was an error while loading. Please reload this page.
| return cb(`${party} login failed or ${party} did not connect to LeetCode`); | ||
| } | ||
| let cookieData = {}; | ||
| if (leetcodeUrl.includes('cn')) { |
Uh oh!
There was an error while loading. Please reload this page.
| requestLeetcodeAndSave(_request, leetcodeUrl, user, cb, config.sys.login_methods.GitHub); | ||
| }); | ||
| } else { | ||
| requestLeetcodeAndSave(_request, leetcodeUrl, user, cb, config.sys.login_methods.GitHub); |
There was a problem hiding this comment.
Can the calling of requestLeetcodeAndSave in line 648 and line 651 merged into one call -- move it out of the if-else block?
There was a problem hiding this comment.
Sorry, these two are with different session(_request), the first one is two-factor, the second one is normal. Both need.
There was a problem hiding this comment.
I see. How about
if(resp.request.uri.href!==urls.github_tf_redirect){returnrequestLeetcodeAndSave(_request,leetcodeUrl,user,cb,config.sys.login_methods.GitHub);}cb('Your GitHub are using two-factor authentication');// read two-factor code must be sync.consttwoFactorcode=require('prompt-sync')()('Please enter your two-factor code: ');constauthenticityTokenTwoFactor=body.match(/name="authenticity_token"value="(.*?)"/);if(authenticityTokenTwoFactor===null){returncb('Get GitHub two-factor token failed');}constoptionsTwoFactor={url: urls.github_tf_session_request,method: 'POST',headers: {'Content-Type': 'application/x-www-form-urlencoded',},followAllRedirects: true,form: {'otp': twoFactorcode,'authenticity_token': authenticityTokenTwoFactor[1],'utf8': encodeURIComponent('✓'),},};_request(optionsTwoFactor,function(e,resp,body){if(resp.request.uri.href===urls.github_tf_session_request){returncb('Invalid two-factor code please check');}requestLeetcodeAndSave(_request,leetcodeUrl,user,cb,config.sys.login_methods.GitHub);});which can save some indentions.
There was a problem hiding this comment.
Yes! Very clean code. Thank you.
Uh oh!
There was an error while loading. Please reload this page.
…e if cn test) to make it more clear, also fixed a tiny bug before
| plugin: 'https://raw.githubusercontent.com/leetcode-tools/leetcode-cli-plugins/master/plugins/$name.js' | ||
| }, | ||
| // login methods enum | ||
| login_methods: { |
E011011101001
commented
Mar 16, 2022
Did this PR make cookie login unusable? In When I was running this tool trying to login by cookie, I got a error says |


…rompt-sync
Solve two-factor auth problem and format some code.
Please help me check if this way can use in vscode-leetcode or not, because I did not find a way, thank you very much.