Skip to content

Cannot login due to undefined id_hash #92

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

Closed
ctanpf opened this issue Mar 6, 2018 · 7 comments
Closed

Cannot login due to undefined id_hash #92

ctanpf opened this issue Mar 6, 2018 · 7 comments
Labels

Comments

@ctanpf
Copy link

ctanpf commented Mar 6, 2018

Problem Summary

How to reproduce

  1. leetcode user -l -vv
  2. Getting id_hash undefined at leetcode.js, expecting login success
[TRACE] REQUEST %s end event https://leetcode.com/list/api/questions
[TRACE] REQUEST %s has body https://leetcode.com/list/api/questions 38249
[TRACE] REQUEST %s emitting complete https://leetcode.com/list/api/questions
/Users/cliff.tan/workspace/misc/leetcode-cli/lib/plugins/leetcode.js:461
    user.hash = favorite.id_hash;
                         ^

TypeError: Cannot read property 'id_hash' of undefined
    at /Users/cliff.tan/workspace/misc/leetcode-cli/lib/plugins/leetcode.js:461:26
    at Request._callback (/Users/cliff.tan/workspace/misc/leetcode-cli/lib/plugins/leetcode.js:376:12)
    at Request.self.callback (/Users/cliff.tan/node_modules/request/request.js:186:22)
    at Request.emit (events.js:159:13)
    at Request.<anonymous> (/Users/cliff.tan/node_modules/request/request.js:1163:10)
    at Request.emit (events.js:159:13)
    at IncomingMessage.<anonymous> (/Users/cliff.tan/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:254:19)
    at IncomingMessage.emit (events.js:164:20)
    at endReadableNT (_stream_readable.js:1054:12)

Environment

  • leetcode-cli version: 2.5.1
  • git last commit: 1cee26c
  • OS version: macOS High Sierra 10.13.3
  • Node version: 9.2.1
  • Npm version: 5.6.0
@ctanpf
Copy link
Author

ctanpf commented Mar 6, 2018

correct me if I'm wrong, but this happens when it is trying to hit the https://leetcode.com/list/api/questions endpoint. Is there any changes around this endpoint?

@ctanpf
Copy link
Author

ctanpf commented Mar 6, 2018

I fixed that by commenting out line 461 in /lib/plugins/leetcode.js but I'm not sure if that's a long term solution.

plugin.getUser = function(user, cb) {
  plugin.getFavorites(function(e, favorites) {
    if (e) return cb(e);

    const favorite = favorites.favorites.private_favorites.find(function(f) {
      return f.name === 'Favorite';
    });
    //user.hash = favorite.id_hash;
    user.name = favorites.user_name;
    session.saveUser(user);
    return cb(null, user);
  });
};

@skygragon
Copy link
Owner

Do you ever have "star" any questions no matter via cli or website? If not, that might be a bug that "https://leetcode.com/list/api/questions" would return without a valid id_hash.

@skygragon skygragon added the bug label Mar 7, 2018
@ctanpf
Copy link
Author

ctanpf commented Mar 7, 2018

I do have some favorite questions on website (not star though). I have removed all favorite questions on website and uncomment line 461 but it still complained about the hash

@skygragon
Copy link
Owner

@ptopenny anyway this error should not block your login action, you can ignore this error and do other actions as usual, e.g. list, show.

@futuristek
Copy link

After removing the stars from favorite list, I was able to login.

skygragon added a commit that referenced this issue May 31, 2018
refs #92

Signed-off-by: Eric Wang <[email protected]>
@rojiani
Copy link

rojiani commented Aug 29, 2018

After setting my Favorites list to private, I no longer received this error...

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

No branches or pull requests

4 participants