Skip to content

Commit

Permalink
Merge pull request #1134 from thailyn/fix-login
Browse files Browse the repository at this point in the history
Do not go to login page for "login" process.
  • Loading branch information
thailyn authored Oct 22, 2021
2 parents 241212e + b3ab8f8 commit 0ac32e5
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions POEApi.Transport/HttpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected enum HttpMethod { GET, POST }
private string _proxyDomain;

private const string LoginURL = @"https://www.pathofexile.com/login";
private const string AccountURL = @"https://www.pathofexile.com/my-account";
private const string AccountNameURL = @"https://www.pathofexile.com/character-window/get-account-name?realm={0}";
private const string CharacterURL = @"https://www.pathofexile.com/character-window/get-characters?&realm={0}";
private const string StashURL = @"https://www.pathofexile.com/character-window/get-stash-items?league={0}&tabs=1&tabIndex={1}&accountName={2}&realm={3}";
Expand Down Expand Up @@ -80,21 +81,8 @@ public bool Authenticate(string email, SecureString password)

credentialCookies.Add(new Cookie("POESESSID", unwrappedPassword, "/", ".pathofexile.com"));

try
{
TraditionalSessionIdLogin();
return true;
}
catch (WebException ex)
{
if (((HttpWebResponse)ex.Response).Server == "cloudflare" && ((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.ServiceUnavailable)
{
CloudFlareSessionIdLogin();
return true;
}

throw;
}
TraditionalSessionIdLogin();
return true;
}

private void CloudFlareSessionIdLogin()
Expand Down Expand Up @@ -126,11 +114,12 @@ private void CloudFlareSessionIdLogin()

private void TraditionalSessionIdLogin()
{
using (var sessionIdLoginResponse = BuildHttpRequestAndGetResponse(HttpMethod.GET, LoginURL))
using (var sessionIdLoginResponse = BuildHttpRequestAndGetResponse(HttpMethod.GET, AccountURL))
{
// If the response URI is the login URL, then the login action failed.
if (sessionIdLoginResponse.ResponseUri.ToString() == LoginURL)
if (sessionIdLoginResponse.ResponseUri.ToString() != AccountURL)
{
throw new LogonFailedException();
}
}
}

Expand Down

0 comments on commit 0ac32e5

Please sign in to comment.