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

Commit 887514f

Browse files
Responding to error messages
1 parent 7c350d9 commit 887514f

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ string password
184184
throw new TwoFactorRequiredException();
185185
}
186186

187+
if (ret.IsBadCredentials)
188+
{
189+
throw new Exception("Bad credentials.");
190+
}
191+
192+
if (ret.IsLocked)
193+
{
194+
throw new Exception("Account locked.");
195+
}
196+
187197
if (ret.Output.Any())
188198
{
189199
throw new Exception(string.Join(Environment.NewLine, ret.Output));
@@ -227,6 +237,23 @@ string code
227237
return ret.Output[0];
228238
}
229239

240+
if (ret.IsTwoFactorRequired)
241+
{
242+
keychain.SetToken(host, ret.Output[0]);
243+
await keychain.Save(host);
244+
throw new TwoFactorRequiredException();
245+
}
246+
247+
if (ret.IsBadCredentials)
248+
{
249+
throw new Exception("Bad credentials.");
250+
}
251+
252+
if (ret.IsLocked)
253+
{
254+
throw new Exception("Account locked.");
255+
}
256+
230257
if (ret.Output.Any())
231258
{
232259
throw new Exception(string.Join(Environment.NewLine, ret.Output));
@@ -260,6 +287,7 @@ internal LoginResultData(LoginResultCodes code, string message, UriString host)
260287

261288
class TwoFactorRequiredException : Exception
262289
{
263-
290+
public TwoFactorRequiredException() : base("Two-Factor authentication required.")
291+
{ }
264292
}
265293
}

0 commit comments

Comments
 (0)