fix: support gists through GitHub App login (#875)

* fix: prompt OAuth reconnection when gist credentials are rejected

* fix: support gist reads through GitHub App user grants

* test: adapt truncated gist regression to provider selection

* fix: address gist reconnect visibility and token renewal review

* fix: verify App authorization before revoking OAuth
This commit is contained in:
Thomas Durieux authored and GitHub committed 2026-10-08 10:26:13 +01:00
1 parent 4fd31a59c8
commit db966356ec
14 files changed
+283 -54

No files matched your search

+12 -5
View File
@@ -1147,11 +1147,16 @@ export const anonymizeController = function (state, http, html, params, location
state.githubConnection = undefined;
state.githubConnections = null;
state.gistOAuthRequired = false;
state.gistAppRequired = false;
const saveGitHubDraft = () => {
const draft = {};
for (const key of ["sourceUrl", "terms", "repoId", "pullRequestId", "gistId", "source", "options", "conference", "githubConnection"]) draft[key] = state[key];
sessionStorage.setItem("github-access-draft", JSON.stringify({ path: location.path(), savedAt: Date.now(), draft }));
};
state.connectGistApp = () => {
saveGitHubDraft();
window.location.href = "/github/app/login?returnTo=" + encodeURIComponent(location.path());
};
state.connectGistOAuth = () => {
saveGitHubDraft();
window.location.href = "/github/login?returnTo=" + encodeURIComponent(location.path());
@@ -1450,6 +1455,7 @@ export const anonymizeController = function (state, http, html, params, location
state.html_readme = "";
state.detectedType = null;
state.gistOAuthRequired = false;
state.gistAppRequired = false;
state._preservingDraft = preserveSelection;
try {
@@ -1770,11 +1776,7 @@ export const anonymizeController = function (state, http, html, params, location
try {
resetValidity();
state.gistOAuthRequired = false;
if (state.githubConnections?.oauthConnected === false) {
state.gistOAuthRequired = true;
setValidity("sourceUrl", "missing", false);
return;
}
state.gistAppRequired = false;
const res = await http.get(`/api/gist/source/${o.gistId}`);
if (!isCurrentSource(request)) return;
state.details = res.data;
@@ -1783,6 +1785,11 @@ export const anonymizeController = function (state, http, html, params, location
}
} catch (error) {
if (!isCurrentSource(request)) return;
if (error.data?.error === "github_app_reconnect_required") {
state.gistAppRequired = true;
setValidity("sourceUrl", "missing", false);
return;
}
if (error.data?.error === "github_oauth_required") {
state.gistOAuthRequired = true;
setValidity("sourceUrl", "missing", false);