Skip to content
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

add third party github login for future updates in vscode-leetcode #34

Merged
merged 5 commits into from
Dec 24, 2019
Merged

add third party github login for future updates in vscode-leetcode #34

merged 5 commits into from
Dec 24, 2019

Conversation

yihong0618
Copy link

@yihong0618 yihong0618 commented Dec 16, 2019

Add third party github login for future updates in vscode-leetcode and somehow solve the recaptcha problem.

Users only need to connect github(or already connected) can use leetcode user -g can login leetcode in leetcode-cli and future for vscode-leetcode(other third parties also can add except google... I will add it if necessary)

how to connect github

  1. find profile page (https://leetcode.com/profile/account/)
  2. link your github id like below
  3. Or user use github to login leetcode at the first will also work
  4. use github account can login to leetcode
    image

@jdneo
Copy link

jdneo commented Dec 16, 2019

Will take a look at the PR before the end of this week. Thank you @yihong0618

Copy link

@jdneo jdneo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong.
If the user enables two-factor auth in GitHub, this method won't able to login, I'm I right?

README.md Outdated Show resolved Hide resolved
lib/commands/user.js Outdated Show resolved Hide resolved
@yihong0618
Copy link
Author

yihong0618 commented Dec 17, 2019

And I tonight I will add Linkedin login maybe, Facebook has a little problem, Google will not work
I think in vscode-leetcode just one third party login will be nice, user can just select their way to login.
And just to change singin method in vscode-leetcode will be easy.

@jdneo
Copy link

jdneo commented Dec 18, 2019

Hmm, actually I failed to login using my GitHub account. Does your GitHub account enable the two-factor auth?

@yihong0618
Copy link
Author

yihong0618 commented Dec 18, 2019

Hmm, actually I failed to login using my GitHub account. Does your GitHub account enable the two-factor auth?
Sorry, two-factor auth is not support for now
Mine is fine. I will test another account.

  1. No my account not enable two-factor auth
  2. Did you use your Github accout not your leetcode accout
  3. Did you link your Github accout to leetcode in leetcode.
  4. Can you try to linkedin accout either, because I only have one, sorry for that.

@jdneo
Copy link

jdneo commented Dec 18, 2019

Sure I'll try with LinkedIn later tonight...

@yihong0618
Copy link
Author

image
I sign up a new accout that use github accout at the first time.
If its a new accout you must verity your email in leetcode and email accout, maybe you miss that?

@jdneo
Copy link

jdneo commented Dec 18, 2019

It should be verified before. The account already connected.

image

Could you try enable the 2-factor auth for your GitHub account? You can find it in the Settings > Security

@yihong0618
Copy link
Author

It should be verified before. The account already connected.

image

Could you try enable the 2-factor auth for your GitHub account? You can find it in the Settings > Security

Trying.....
But I found no +86(China) for sms

@yihong0618
Copy link
Author

It should be verified before. The account already connected.

image

Could you try enable the 2-factor auth for your GitHub account? You can find it in the Settings > Security

And I think you can disconnect and connect another Github account for test.
Before that you should logout your github account in chrome because leetcode connect will read your session

@jdneo
Copy link

jdneo commented Dec 18, 2019

Tried another GitHub account without 2-factor auth, and login successfully.

So I think we can first hint to user that 2-factor auth is not supported yet. And spend some time to see if it is possible to enable it.

Copy link

@jdneo jdneo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well Done!

_request.get({url: leetcodeUrl}, function(e, resp, body) {
const redirectUri = resp.request.uri.href;
if (redirectUri !== 'https://leetcode.com/') {
return cb('GitHub login failed or GitHub did not link to leetcode');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leetcode -> LeetCode

});
_request('https://www.linkedin.com', function(e, resp, body) {
if ( resp.statusCode !== 200) {
return cb('Get linkedin session failed');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linkedin -> LinkedIn

}
const authenticityToken = body.match(/input name="loginCsrfParam" value="(.*)" /);
if (authenticityToken === null) {
return cb('Get Linkedin token failed');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LinkedIn

_request.get({url: leetcodeUrl}, function(e, resp, body) {
const redirectUri = resp.request.uri.href;
if (redirectUri !== 'https://leetcode.com/') {
return cb('Linkedin login failed or Linkedin did not link to leetcode');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LinkedIn

LeetCode

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that, I will correct them~
Thank you very much for your help ~

@yihong0618
Copy link
Author

Tried another GitHub account without 2-factor auth, and login successfully.

So I think we can first hint to user that 2-factor auth is not supported yet. And spend some time to see if it is possible to enable it.

OK, seems a little hard but I will try.
And facebook way I think it is not worth because I use m.facebook.com a hack way to login.
Although successful but cause the facebook security alert, so I deleted the method.

@jdneo
Copy link

jdneo commented Dec 18, 2019

Yes, no need to support facebook at this time. GitHub and LinkedIn are good enough!

@jdneo
Copy link

jdneo commented Dec 24, 2019

Thank you @yihong0618.

Would you like me to publish a new release for this change?

@jdneo jdneo merged commit 1f26fbd into leetcode-tools:master Dec 24, 2019
@yihong0618
Copy link
Author

Yes.
And I found a way to solve the two-factor code. But it will use another package.
And I am not sure if it could be work in vscode-leetcode.
So I will have another pr, can you help me with that to check if the two-factor can be used in vscode-leetcode.
Thank you very much. The new pr will send in 10-20 minutes.
Thanks again.

@jdneo
Copy link

jdneo commented Dec 25, 2019

@yihong0618 Sure! Will the PR you mentioned be raised in this repo?

@yihong0618
Copy link
Author

@jdneo
Yes, see this #35
Thank you very much!

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

Successfully merging this pull request may close these issues.

3 participants