try to fix repo access

This commit is contained in:
Thomas Durieux
2025-04-01 22:27:17 +02:00
parent c2a423714f
commit b2d77faa6c
4 changed files with 33 additions and 11 deletions
+5
View File
@@ -10,6 +10,7 @@ import config from "../../config";
import UserModel from "../../core/model/users/users.model";
import { IUserDocument } from "../../core/model/users/users.types";
import AnonymousError from "../../core/AnonymousError";
import AnonymizedPullRequestModel from "../../core/model/anonymizedPullRequests/anonymizedPullRequests.model";
export function ensureAuthenticated(
req: express.Request,
@@ -33,6 +34,10 @@ const verify = async (
user = await UserModel.findOne({ "externalIDs.github": profile.id });
if (user) {
user.accessTokens.github = accessToken;
await AnonymizedPullRequestModel.updateMany(
{ owner: user._id },
{ "source.accessToken": accessToken }
);
} else {
const photo = profile.photos ? profile.photos[0]?.value : null;
user = new UserModel({