Skip to content

cannot log in #611

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

Open
fengchunqi opened this issue Aug 5, 2020 · 2 comments
Open

cannot log in #611

fengchunqi opened this issue Aug 5, 2020 · 2 comments

Comments

@fengchunqi
Copy link

i cannot log in this

  • vscode: v1.47.3
  • node: v12.18.3
  • leetcode: v0.17.0

errorInfo

leetcode.vscode-leetcode-0.17.0\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:589
const authenticityToken = body.match(/name="authenticity_token" value="(.*?)"/);
^
TypeError: Cannot read property 'match' of undefined

plugin.githubLogin = function(user, cb) {
  const urls = config.sys.urls;
  const leetcodeUrl = urls.github_login;
  const _request = request.defaults({jar: true});
  _request(urls.github_login_request, function(e, resp, body) {
    const authenticityToken = body.match(/name="authenticity_token" value="(.*?)"/); // The problem is here
    let gaId = body.match(/name="ga_id" value="(.*?)"/);
    if (!gaId) {
      gaId = '';
    }
    let requiredField = body.match(/name="required_field_(.*?)"/);
    const timestamp = body.match(/name="timestamp" value="(.*?)"/);
    const timestampSecret = body.match(/name="timestamp_secret" value="(.*?)"/);
@elinx
Copy link

elinx commented Dec 24, 2020

@frenchleave1007 I meet the same problem and after digging around a few moments I figured out it's because I work under corporation's proxy and thus suffer from certification issue. You could first add the following 3 lines to get the error message:

  _request(urls.github_login_request, function(e, resp, body) {
    if (e || resp.statusCode != 200 || body == null) { // 1
      return cb('GitHub login failed ' + e); // 2
    }  // 3
    const authenticityToken = body.match(/name="authenticity_token" value="(.*?)"/);

If you get the first certificate problem like me then add the following line of code to the beginning of this file, reload vscode, it would works for sign in to leetcode:

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0

After sign in, you'd better set the enviroment variable back to 1 for security reason.

@WinnieeBear
Copy link

I set the vscode proxy to resolve this issue. You can have a try. Mostly it's the network issue, as you know to visit GitHub you may need some proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants