mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-21 15:02:39 +02:00
fix: close account authorization gaps (#755)
This commit is contained in:
1 parent
aab6ccf7fc
commit
beef8387ae
7 files changed
+176
-28
No files matched your search
@@ -5,6 +5,8 @@ import { ensureAuthenticated } from "./connection";
|
||||
import { handleError, getUser, isOwnerOrAdmin } from "./route-utils";
|
||||
import UserModel from "../../core/model/users/users.model";
|
||||
import AnonymizedRepositoryModel from "../../core/model/anonymizedRepositories/anonymizedRepositories.model";
|
||||
import AnonymizedPullRequestModel from "../../core/model/anonymizedPullRequests/anonymizedPullRequests.model";
|
||||
import AnonymizedGistModel from "../../core/model/anonymizedGists/anonymizedGists.model";
|
||||
import User from "../../core/User";
|
||||
import FileModel from "../../core/model/files/files.model";
|
||||
import { isConnected } from "../database";
|
||||
@@ -170,6 +172,23 @@ router.delete("/", async (req: express.Request, res: express.Response) => {
|
||||
if (gist.status !== "removed") await gist.remove();
|
||||
}
|
||||
|
||||
// Removal keeps anonymized records as tombstones, so explicitly erase the
|
||||
// duplicated OAuth credentials stored on each source record.
|
||||
await Promise.all([
|
||||
AnonymizedRepositoryModel.updateMany(
|
||||
{ owner: user.model._id },
|
||||
{ $unset: { "source.accessToken": "" } }
|
||||
).exec(),
|
||||
AnonymizedPullRequestModel.updateMany(
|
||||
{ owner: user.model._id },
|
||||
{ $unset: { "source.accessToken": "" } }
|
||||
).exec(),
|
||||
AnonymizedGistModel.updateMany(
|
||||
{ owner: user.model._id },
|
||||
{ $unset: { "source.accessToken": "" } }
|
||||
).exec(),
|
||||
]);
|
||||
|
||||
// Revoke the OAuth grant so the application no longer appears in the
|
||||
// user's GitHub authorized applications. Best-effort: the account is
|
||||
// scrubbed even if GitHub rejects the revocation.
|
||||
|
||||
Reference in new issue
Block a user