Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 2f75f25

Browse files
Merge branch 'fixes/octorun-is-custom' into fixes/octorun-refactor-authentication
2 parents f8f1bfc + ff0ae27 commit 2f75f25

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

octorun/src/authentication.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var lockedRegex = new RegExp("number of login attempts exceeded", "gi");
88
var twoFactorRegex = new RegExp("must specify two-factor authentication otp code", "gi");
99
var badCredentialsRegex = new RegExp("bad credentials", "gi");
1010

11+
var lockedErrorMessage = "locked";
12+
var badCredentialsErrorMessage = "badcredentials";
13+
1114
var handleBasicAuthentication = function (username, password, onSuccess, onRequiresTwoFa, onFailure) {
1215
var octokit = octokitWrapper.createOctokit();
1316

@@ -28,10 +31,10 @@ var handleBasicAuthentication = function (username, password, onSuccess, onRequi
2831
onRequiresTwoFa();
2932
}
3033
else if (lockedRegex.test(err.message)) {
31-
onFailure("Account locked.")
34+
onFailure(lockedErrorMessage)
3235
}
3336
else if (badCredentialsRegex.test(err.message)) {
34-
onFailure("Bad credentials.")
37+
onFailure(badCredentialsErrorMessage)
3538
}
3639
else {
3740
onFailure(err)
@@ -63,10 +66,10 @@ var handleTwoFactorAuthentication = function (username, password, twoFactor, onS
6366
}, function (err, res) {
6467
if (err) {
6568
if (lockedRegex.test(err.message)) {
66-
onFailure("Account locked.")
69+
onFailure(lockedErrorMessage)
6770
}
6871
else if (badCredentialsRegex.test(err.message)) {
69-
onFailure("Bad credentials.")
72+
onFailure(badCredentialsErrorMessage)
7073
}
7174
else {
7275
onFailure(err)

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ string password
177177
return ret.Output[0];
178178
}
179179

180-
if (ret.IsCustom && ret.Status == "2fa")
180+
if (ret.IsTwoFactorRequired)
181181
{
182182
keychain.SetToken(host, ret.Output[0]);
183183
await keychain.Save(host);

src/GitHub.Api/Tasks/OctorunTask.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ public OctorunResult(string status, string[] output)
123123

124124
public bool IsSuccess => Status.Equals("success", StringComparison.InvariantCultureIgnoreCase);
125125
public bool IsError => Status.Equals("error", StringComparison.InvariantCultureIgnoreCase);
126-
public bool IsCustom => !IsSuccess && !IsError;
126+
public bool IsTwoFactorRequired => Status.Equals("2fa", StringComparison.InvariantCultureIgnoreCase);
127+
public bool IsLocked => Status.Equals("locked", StringComparison.InvariantCultureIgnoreCase);
128+
public bool IsBadCredentials => Status.Equals("badcredentials", StringComparison.InvariantCultureIgnoreCase);
127129
}
128130
}

0 commit comments

Comments
 (0)