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

Commit ff0ae27

Browse files
Returning IsLocked and IsBadCredentials
1 parent 30fcc90 commit ff0ae27

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
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/Tasks/OctorunTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,7 @@ public OctorunResult(string status, string[] output)
124124
public bool IsSuccess => Status.Equals("success", StringComparison.InvariantCultureIgnoreCase);
125125
public bool IsError => Status.Equals("error", StringComparison.InvariantCultureIgnoreCase);
126126
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)