Skip to content

Commit

Permalink
reg/dereg fix auth
Browse files Browse the repository at this point in the history
  • Loading branch information
pratyush3124 committed Mar 16, 2024
1 parent 67f6af0 commit 69d6784
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 21 deletions.
1 change: 0 additions & 1 deletion app/api/event1/deleteTeam/[teamId]/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/api/event1/deregister/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event1/register/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event3/deregister/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event3/register/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event4/deregister/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event4/register/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event5/deregister/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event5/register/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event6/deregister/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/api/event6/register/route.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down

0 comments on commit 69d6784

Please sign in to comment.