Prefer instance GitHub credentials to global ones

This commit is contained in:
Cyberboss
2018-09-19 14:16:31 -04:00
parent bdd7f5f5dc
commit efd347bfbd
@@ -533,7 +533,11 @@ namespace Tgstation.Server.Host.Controllers
foreach (var I in model.NewTestMerges.Where(x => String.IsNullOrWhiteSpace(x.PullRequestRevision)))
I.PullRequestRevision = null;
var gitHubClient = String.IsNullOrEmpty(generalConfiguration.GitHubAccessToken) ? (currentModel.AccessToken != null ? gitHubClientFactory.CreateClient(currentModel.AccessToken) : gitHubClientFactory.CreateClient()) : gitHubClientFactory.CreateClient(generalConfiguration.GitHubAccessToken);
var gitHubClient = currentModel.AccessToken != null
? gitHubClientFactory.CreateClient(currentModel.AccessToken)
: (String.IsNullOrEmpty(generalConfiguration.GitHubAccessToken)
? gitHubClientFactory.CreateClient()
: gitHubClientFactory.CreateClient(generalConfiguration.GitHubAccessToken));
var repoOwner = repo.GitHubOwner;
var repoName = repo.GitHubRepoName;
@@ -665,6 +669,10 @@ namespace Tgstation.Server.Host.Controllers
//you look at your anonymous access and sigh
errorMessage = "P.R.E. RATE LIMITED";
}
catch (Octokit.AuthorizationException)
{
errorMessage = "P.R.E. BAD CREDENTIALS";
}
catch (Octokit.NotFoundException)
{
//you look at your shithub and sigh