Skip to content

Commit

Permalink
modified verifyRole.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
PurnenduMIshra129th committed Jan 28, 2025
1 parent 8a93c8f commit 2225a9d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/resolvers/Query/verifyRole.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { InterfaceJwtTokenPayload } from "@utilities/auth";
import type { QueryResolvers } from "../../types/generatedGraphQLTypes";
import jwt from "jsonwebtoken";
import type {
InterfaceAppUserProfile} from "../../models/AppUserProfile";
import {
AppUserProfile
} from "../../models/AppUserProfile";
import type { InterfaceAppUserProfile } from "../../models/AppUserProfile";
import { AppUserProfile } from "../../models/AppUserProfile";
import type { Request } from "express";
/**
* This query verifies the user's role based on the provided JWT token.
* @param _ - Unused parent parameter (as this is a root-level query).
Expand All @@ -23,7 +21,6 @@ import {
* - Returns the role and authorization status.
*/

import type { Request } from "express";
export const verifyRole: QueryResolvers["verifyRole"] = async (
_: unknown,
args: unknown,
Expand All @@ -39,7 +36,6 @@ export const verifyRole: QueryResolvers["verifyRole"] = async (

// const token = authHeader.split(' ')[1]; // Assuming "Bearer <token>" format
const token = authHeader;
console.log("token", token);
if (!token) {
return { role: "", isAuthorized: false };
}
Expand All @@ -48,7 +44,6 @@ export const verifyRole: QueryResolvers["verifyRole"] = async (
token,
process.env.ACCESS_TOKEN_SECRET as string,
);
console.log("decoded", decoded);
const decodedToken = decoded as InterfaceJwtTokenPayload;
const appUserProfile: InterfaceAppUserProfile | null =
await AppUserProfile.findOne({
Expand Down

0 comments on commit 2225a9d

Please sign in to comment.