Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refine the result parsing logic#501

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jdneo merged 2 commits intomasterfromcs/login
Jan 12, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
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
18 changes: 9 additions & 9 deletionspackage-lock.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -683,6 +683,6 @@
"markdown-it": "^8.4.2",
"require-from-string": "^2.0.2",
"unescape-js": "^1.1.1",
"vsc-leetcode-cli": "2.6.20"
"vsc-leetcode-cli": "2.6.22"
}
}
33 changes: 17 additions & 16 deletionssrc/leetCodeManager.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,8 @@ import * as wsl from "./utils/wslUtils";
class LeetCodeManager extends EventEmitter {
private currentUser: string | undefined;
private userStatus: UserStatus;
private readonly successRegex: RegExp = /(?:.*)Successfully .*login as (.*)/i;
private readonly failRegex: RegExp = /.*\[ERROR\].*/i;

constructor() {
super();
Expand DownExpand Up@@ -42,11 +44,6 @@ class LeetCodeManager extends EventEmitter {
detail: "Use LeetCode account to login",
value: "LeetCode",
},
{
label: "LeetCode Cookie",
detail: "Use LeetCode cookie copied from browser to login",
value: "Cookie",
},
{
label: "Third-Party: GitHub",
detail: "Use GitHub account to login",
Expand All@@ -57,6 +54,11 @@ class LeetCodeManager extends EventEmitter {
detail: "Use LinkedIn account to login",
value: "LinkedIn",
},
{
label: "LeetCode Cookie",
detail: "Use LeetCode cookie copied from browser to login",
value: "Cookie",
},
);
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(picks);
if (!choice) {
Expand DownExpand Up@@ -87,20 +89,22 @@ class LeetCodeManager extends EventEmitter {
if (data.includes("twoFactorCode")) {
const twoFactor: string | undefined = await vscode.window.showInputBox({
prompt: "Enter two-factor code.",
ignoreFocusOut: true,
validateInput: (s: string): string | undefined => s && s.trim() ? undefined : "The input must not be empty",
});
if (!twoFactor) {
childProc.kill();
return resolve(undefined);
}
childProc.stdin.write(`${twoFactor}\n`);
}
const successMatch: RegExpMatchArray | null = data.match(this.successRegex);
if (successMatch && successMatch[1]) {
childProc.stdin.end();
} else {
const match: RegExpMatchArray | null = data.match(/(?:.*)Successfully .*login as (.*)/i);
if (match && match[1]) {
childProc.stdin.end();
return resolve(match[1]);
}
return resolve(successMatch[1]);
} else if (data.match(this.failRegex)) {
childProc.stdin.end();
return reject(new Error("Faile to login"));
}
});

Expand All@@ -109,6 +113,7 @@ class LeetCodeManager extends EventEmitter {
childProc.on("error", reject);
const name: string | undefined = await vscode.window.showInputBox({
prompt: "Enter username or E-mail.",
ignoreFocusOut: true,
validateInput: (s: string): string | undefined => s && s.trim() ? undefined : "The input must not be empty",
});
if (!name) {
Expand All@@ -119,18 +124,14 @@ class LeetCodeManager extends EventEmitter {
const pwd: string | undefined = await vscode.window.showInputBox({
prompt: isByCookie ? "Enter cookie" : "Enter password.",
password: true,
ignoreFocusOut: true,
validateInput: (s: string): string | undefined => s ? undefined : isByCookie ? "Cookie must not be empty" : "Password must not be empty",
});
if (!pwd) {
childProc.kill();
return resolve(undefined);
}
childProc.stdin.write(`${pwd}\n`);
childProc.on("close", (code: number) => {
if (code !== 0) {
reject(new Error("Failed to login."));
}
});
});
if (userName) {
vscode.window.showInformationMessage(`Successfully ${inMessage}.`);
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp