diff --git a/app/api/event1/deleteTeam/[teamId]/route.js b/app/api/event1/deleteTeam/[teamId]/route.js index b8b570c..df99aea 100644 --- a/app/api/event1/deleteTeam/[teamId]/route.js +++ b/app/api/event1/deleteTeam/[teamId]/route.js @@ -12,7 +12,6 @@ export async function POST(req,{params}){ try{ await connectMongoDB(); - const headers = req.headers; const token = await getToken({req}) const auth = token ? token.accessTokenFromBackend : null diff --git a/app/api/event1/deregister/route.js b/app/api/event1/deregister/route.js index de97e49..19039f3 100644 --- a/app/api/event1/deregister/route.js +++ b/app/api/event1/deregister/route.js @@ -1,12 +1,14 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, _) { try { await connectMongoDB(); - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event1/register/route.js b/app/api/event1/register/route.js index 29f9939..7925159 100644 --- a/app/api/event1/register/route.js +++ b/app/api/event1/register/route.js @@ -1,13 +1,15 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, res) { try { await connectMongoDB(); const headers = req.headers; - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event3/deregister/route.js b/app/api/event3/deregister/route.js index 10015c9..042e3a8 100644 --- a/app/api/event3/deregister/route.js +++ b/app/api/event3/deregister/route.js @@ -1,12 +1,14 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, _) { try { await connectMongoDB(); - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event3/register/route.js b/app/api/event3/register/route.js index 2d2eb44..037533a 100644 --- a/app/api/event3/register/route.js +++ b/app/api/event3/register/route.js @@ -1,13 +1,15 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, res) { try { await connectMongoDB(); const headers = req.headers; - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event4/deregister/route.js b/app/api/event4/deregister/route.js index c329152..84ba108 100644 --- a/app/api/event4/deregister/route.js +++ b/app/api/event4/deregister/route.js @@ -1,12 +1,14 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, _) { try { await connectMongoDB(); - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event4/register/route.js b/app/api/event4/register/route.js index 710059d..dd4096a 100644 --- a/app/api/event4/register/route.js +++ b/app/api/event4/register/route.js @@ -1,13 +1,15 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, res) { try { await connectMongoDB(); const headers = req.headers; - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event5/deregister/route.js b/app/api/event5/deregister/route.js index 086a60c..ca02d1c 100644 --- a/app/api/event5/deregister/route.js +++ b/app/api/event5/deregister/route.js @@ -1,12 +1,14 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, _) { try { await connectMongoDB(); - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event5/register/route.js b/app/api/event5/register/route.js index 2b04b46..caf226b 100644 --- a/app/api/event5/register/route.js +++ b/app/api/event5/register/route.js @@ -1,13 +1,15 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, res) { try { await connectMongoDB(); const headers = req.headers; - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event6/deregister/route.js b/app/api/event6/deregister/route.js index bfc6f4a..fe4a0f4 100644 --- a/app/api/event6/deregister/route.js +++ b/app/api/event6/deregister/route.js @@ -1,12 +1,14 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, _) { try { await connectMongoDB(); - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 }); diff --git a/app/api/event6/register/route.js b/app/api/event6/register/route.js index da87019..c8f48cf 100644 --- a/app/api/event6/register/route.js +++ b/app/api/event6/register/route.js @@ -1,13 +1,15 @@ -import { Users } from "@/models/user.model"; import { connectMongoDB } from "@/lib/mongodb"; +import { Users } from "@/models/user.model"; import { getTokenDetails } from "@/utils/authuser"; +import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function GET(req, res) { try { await connectMongoDB(); const headers = req.headers; - const auth = req.headers.get("authorization").split(" ")[1]; + const token = await getToken({req}) + const auth = token ? token.accessTokenFromBackend : null const userId = await getTokenDetails(auth); if (!userId) { return NextResponse.json({ message: "User not found." }, { status: 404 });