Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Protect create company route handler

Khuram Niazfb92dc25c194
diff --git a/apiTest.rest b/apiTest.rest
new file mode 100644
index 0000000..b6f8b11
--- /dev/null
+++ b/apiTest.rest
@@ -0,0 +1,7 @@
+
+POST http://localhost:3002/api/company HTTP/1.1
+content-type: application/json
+
+{
+ "name": "rest Client test 45"
+}
\ No newline at end of file
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 578748d..a93e886 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -54,6 +54,8 @@ model Company {
logoUrl String? // field is optional
}
+//TODO: Add createdBy
+
model JobSource {
id String @id @default(uuid())
name String
@@ -67,6 +69,7 @@ model Interview {
interviewers Contact[]
}
+//TODO: Add jobtype(fulltime, part time, contract)
model Job {
id String @id @default(uuid())
userId String
diff --git a/src/app/api/company/route.ts b/src/app/api/company/route.ts
index 722977c..2608351 100644
--- a/src/app/api/company/route.ts
+++ b/src/app/api/company/route.ts
@@ -1,10 +1,30 @@
import "server-only";
import prisma from "@/lib/db";
-import { NextRequest, NextResponse } from "next/server";
+import { NextResponse } from "next/server";
+import { auth } from "@/auth";
-export async function POST(req: NextRequest) {
- const { name } = await req.json();
+export const POST = async (req: any) => {
+ const session = await auth();
+ console.log("SESSION: ", session);
+ /* SESSION: {
+ user: { name: 'Admin', email: '[email protected]' },
+ expires: '2024-07-04T06:16:33.616Z',
+ accessToken: {
+ name: 'Admin',
+ email: '[email protected]',
+ sub: '24c84c85-b6a9-40ea-bccb-1b883bcc64cd',
+ iat: 1717481780,
+ exp: 1720073780,
+ jti: '4b5bbd8a-aa0e-4552-b19c-82e2c2dbf130'
+ }
+ } */
+ if (!session || !session.user) {
+ return new NextResponse(JSON.stringify({ message: "Not Authenticated" }), {
+ status: 401,
+ });
+ }
+ const { name } = await req.json();
if (!name) {
return NextResponse.json(
{ message: "Company name is required" },
@@ -28,4 +48,4 @@ export async function POST(req: NextRequest) {
{ status: 500 }
);
}
-}
+};
diff --git a/src/auth.ts b/src/auth.ts
index 0b085ad..d7eae3a 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -23,7 +23,6 @@ export const { auth, handlers, signIn, signOut } = NextAuth({
providers: [
Credentials({
async authorize(credentials) {
- console.log("AUTH: ", auth);
const parsedCredentials = z
.object({ email: z.string().email(), password: z.string().min(6) })
.safeParse(credentials);
diff --git a/src/components/ComboBox.tsx b/src/components/ComboBox.tsx
index 2ee82d1..e371984 100644
--- a/src/components/ComboBox.tsx
+++ b/src/components/ComboBox.tsx
@@ -41,7 +41,6 @@ export function Combobox({ options, field, dataKeys }: ComboboxProps) {
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
const [loading, setLoading] = useState(false);
const [key1, key2] = dataKeys;
-
async function onCreateOption(value: string) {
setLoading(true);
try {
@@ -66,7 +65,7 @@ export function Combobox({ options, field, dataKeys }: ComboboxProps) {
variant="outline"
role="combobox"
className={cn(
- "w-[240px] justify-between capitalize",
+ "md:w-[240px] lg:w-[280px] justify-between capitalize",
!field.value && "text-muted-foreground"
)}
>
@@ -82,7 +81,7 @@ export function Combobox({ options, field, dataKeys }: ComboboxProps) {
</Button>
</FormControl>
</PopoverTrigger>
- <PopoverContent className="w-[240px] p-0">
+ <PopoverContent className="md:w-[240px] lg:w-[280px] p-0">
<Command>
<CommandInput
value={newOption}
diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsx
index ae96739..65b4f61 100644
--- a/src/components/DatePicker.tsx
+++ b/src/components/DatePicker.tsx
@@ -38,7 +38,7 @@ export function DatePicker({ field, presets }: DatePickerProps) {
<Button
variant={"outline"}
className={cn(
- "w-[280px] justify-start text-left font-normal",
+ "md:w-[240px] lg:w-[280px] justify-start text-left font-normal",
!field.value && "text-muted-foreground"
)}
>
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index 497961f..cad9f26 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -62,7 +62,7 @@ async function Header() {
</nav>
</SheetContent>
</Sheet>
- <h1>JobSync - Job Tracking System</h1>
+ <h1>JobSync - Job Search Assistant</h1>
<div className="relative ml-auto flex-1 md:grow-0">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input