mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-13 02:42:45 +00:00
fix: Prevent error when repo is not found
This commit is contained in:
@@ -15,7 +15,7 @@ const router = express.Router();
|
||||
|
||||
// get repository information
|
||||
router.get("/:repoId/", async (req: express.Request, res: express.Response) => {
|
||||
const repo = await getRepo(req, res, { nocheck: true });
|
||||
const repo = await getRepo(req, res, { nocheck: false });
|
||||
if (!repo) return;
|
||||
|
||||
try {
|
||||
@@ -75,10 +75,10 @@ router.post("/claim", async (req: express.Request, res: express.Response) => {
|
||||
router.post(
|
||||
"/:repoId/refresh",
|
||||
async (req: express.Request, res: express.Response) => {
|
||||
const repo = await getRepo(req, res, { nocheck: true });
|
||||
if (!repo) return;
|
||||
|
||||
try {
|
||||
const repo = await getRepo(req, res, { nocheck: true });
|
||||
if (!repo) throw new Error("repo_not_found");
|
||||
|
||||
const user = await getUser(req);
|
||||
if (repo.owner.username != user.username) {
|
||||
return res.status(401).json({ error: "not_authorized" });
|
||||
@@ -220,17 +220,17 @@ function updateRepoModel(model: IAnonymizedRepositoryDocument, repoUpdate) {
|
||||
router.post(
|
||||
"/:repoId/",
|
||||
async (req: express.Request, res: express.Response) => {
|
||||
const repo = await getRepo(req, res, { nocheck: true });
|
||||
if (!repo) return;
|
||||
const user = await getUser(req);
|
||||
|
||||
if (repo.owner.username != user.username) {
|
||||
return res.status(401).json({ error: "not_authorized" });
|
||||
}
|
||||
|
||||
const repoUpdate = req.body;
|
||||
|
||||
try {
|
||||
const repo = await getRepo(req, res, { nocheck: true });
|
||||
if (!repo) throw new Error("repo_not_found");
|
||||
const user = await getUser(req);
|
||||
|
||||
if (repo.owner.username != user.username) {
|
||||
return res.status(401).json({ error: "not_authorized" });
|
||||
}
|
||||
|
||||
const repoUpdate = req.body;
|
||||
|
||||
validateNewRepo(repoUpdate);
|
||||
|
||||
if (repoUpdate.commit != repo.model.source.commit) {
|
||||
|
||||
Reference in New Issue
Block a user