Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/me/src/app/api/profile/avatar/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ export async function POST(request: NextRequest) {
const userId = user.id;

const formData = await request.formData();
const file = formData.get("file") as File | null;
const fileValue = formData.get("file");

if (!file) {
if (!(fileValue instanceof File)) {
return NextResponse.json({ error: "No file provided" }, { status: 400 });
}

const file = fileValue;

if (!ALLOWED_TYPES.has(file.type)) {
return NextResponse.json(
{ error: "Invalid file type. Allowed: jpeg, png, webp, gif" },
{ error: "Invalid file type. Allowed: jpeg, png, webp" },
{ status: 400 },
);
}
Expand Down
7 changes: 6 additions & 1 deletion apps/me/src/app/api/profile/positions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export async function DELETE(request: NextRequest) {
positionId: number;
};

if (!body.orgId || !body.positionId) {
if (
body.orgId == null ||
typeof body.orgId !== "number" ||
body.positionId == null ||
typeof body.positionId !== "number"
) {
return NextResponse.json(
{ error: "orgId and positionId are required" },
{ status: 400 },
Expand Down
6 changes: 5 additions & 1 deletion apps/me/src/app/api/profile/roles/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export async function DELETE(request: NextRequest) {
roleName: string;
};

if (!body.orgId || !body.roleName) {
if (
body.orgId == null ||
typeof body.orgId !== "number" ||
!body.roleName
) {
return NextResponse.json(
{ error: "orgId and roleName are required" },
{ status: 400 },
Expand Down
2 changes: 1 addition & 1 deletion apps/me/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UserUpsert {
phone?: string;
homeRegionId?: number | null;
avatarUrl?: string | null;
meta?: string;
meta?: Record<string, unknown>;
emergencyContact?: string | null;
emergencyPhone?: string | null;
emergencyNotes?: string | null;
Expand Down
Loading