Skip to content

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

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

Merged
merged 5 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix typo
  • Loading branch information
yihong0618 committed Dec 18, 2019
commit 57e39f8a0c787e608767edc2ec47407fbd057a63
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Great thanks to leetcode.com, a really awesome website!

Read help first $ leetcode help
Login with your leetcode account $ leetcode user -l
Login with third party account--Github $ leetcode user -g
Login with third party account--GitHub $ leetcode user -g
Login with third party account--Linkedin $ leetcode user -i
Cookie login with cookie $ leetcode user -c
Browse all questions $ leetcode list
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const cmd = {
.example(chalk.yellow('leetcode user'), 'Show current user')
.example(chalk.yellow('leetcode user -l'), 'User login')
.example(chalk.yellow('leetcode user -c'), 'User Cookie login')
.example(chalk.yellow('leetcode user -g'), 'User Github login')
.example(chalk.yellow('leetcode user -g'), 'User GitHub login')
.example(chalk.yellow('leetcode user -i'), 'User Linkedin login')
.example(chalk.yellow('leetcode user -L'), 'User logout');
}
Expand Down
10 changes: 5 additions & 5 deletions lib/plugins/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ plugin.githubLogin = function(user, cb) {
_request('https://github.com/login', function(e, resp, body) {
const authenticityToken = body.match(/name="authenticity_token" value="(.*?)"/);
if (authenticityToken === null) {
return cb('Get github token failed');
return cb('Get GitHub token failed');
}
const options = {
url: 'https://github.com/session',
Expand All @@ -592,12 +592,12 @@ plugin.githubLogin = function(user, cb) {
};
_request(options, function(e, resp, body) {
if (resp.statusCode !== 200) {
return cb('Github login failed');
return cb('GitHub login failed');
}
_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');
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

}
const cookieData = parseCookie(resp.request.headers.cookie, cb);
saveAndGetUser(user, cb, cookieData);
Expand All @@ -620,7 +620,7 @@ plugin.linkinedLogin = function(user, cb) {
}
const authenticityToken = body.match(/input name="loginCsrfParam" value="(.*)" /);
if (authenticityToken === null) {
return cb('Get Linkined token failed');
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

}
const options = {
url: 'https://www.linkedin.com/uas/login-submit',
Expand All @@ -638,7 +638,7 @@ plugin.linkinedLogin = function(user, cb) {
};
_request(options, function(e, resp, body) {
if (resp.statusCode !== 200) {
return cb('Facebook login failed');
return cb('Linkedin login failed');
}
_request.get({url: leetcodeUrl}, function(e, resp, body) {
const redirectUri = resp.request.uri.href;
Expand Down