Skip to content

Commit

Permalink
Only paras and up can upload files
Browse files Browse the repository at this point in the history
  • Loading branch information
canjalal committed Oct 17, 2024
1 parent 2c020f8 commit b1e5c2f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/backend/routers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import {
GetObjectCommand,
} from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { hasAuthenticated, router } from "../trpc";
import { hasPara, router } from "../trpc";
import { randomUUID } from "crypto";
import { deleteFile } from "../lib/files";

export const file = router({
getMyFiles: hasAuthenticated.query(async (req) => {
getMyFiles: hasPara.query(async (req) => {
return req.ctx.db
.selectFrom("file")
.selectAll()
.where("uploaded_by_user_id", "=", req.ctx.auth.userId)
.execute();
}),

getPresignedUrlForFileDownload: hasAuthenticated
getPresignedUrlForFileDownload: hasPara
.input(
z.object({
file_id: z.string().uuid(),
Expand Down Expand Up @@ -50,7 +50,7 @@ export const file = router({
};
}),

getPresignedUrlForFileUpload: hasAuthenticated
getPresignedUrlForFileUpload: hasPara
.input(
z.object({
type: z.string(),
Expand All @@ -71,7 +71,7 @@ export const file = router({
return { url, key };
}),

finishFileUpload: hasAuthenticated
finishFileUpload: hasPara
.input(
z.object({
filename: z.string(),
Expand Down Expand Up @@ -99,7 +99,7 @@ export const file = router({
return file;
}),

deleteFile: hasAuthenticated
deleteFile: hasPara
.input(
z.object({
file_id: z.string().uuid(),
Expand Down

0 comments on commit b1e5c2f

Please sign in to comment.