Skip to content

Commit 7915597

Browse files
committed
fixed naming
1 parent 42976e5 commit 7915597

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/controllers/guildRoleHandler.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import jwt from "@tsndr/cloudflare-worker-jwt";
21
import * as response from "../constants/responses";
32
import { env } from "../typeDefinitions/default.types";
43
import JSONResponse from "../utils/JsonResponse";
@@ -8,15 +7,15 @@ import {
87
createNewRole,
98
memberGroupRole,
109
} from "../typeDefinitions/discordMessage.types";
11-
import { verifyBot } from "../utils/verifyAuthToken";
10+
import { verifyAuthToken } from "../utils/verifyAuthToken";
1211

1312
export async function createGuildRoleHandler(request: IRequest, env: env) {
1413
const authHeader = request.headers.get("Authorization");
1514
if (!authHeader) {
1615
return new JSONResponse(response.BAD_SIGNATURE);
1716
}
1817
try {
19-
await verifyBot(authHeader, env);
18+
await verifyAuthToken(authHeader, env);
2019
const body: createNewRole = await request.json();
2120

2221
const res = await createGuildRole(body, env);
@@ -30,11 +29,8 @@ export async function addGroupRoleHandler(request: IRequest, env: env) {
3029
if (!authHeader) {
3130
return new JSONResponse(response.BAD_SIGNATURE);
3231
}
33-
const authToken = authHeader.split(" ")[1];
3432
try {
35-
await jwt.verify(authToken, env.RDS_SERVERLESS_PUBLIC_KEY, {
36-
algorithm: "RS256",
37-
});
33+
await verifyAuthToken(authHeader, env);
3834
const body: memberGroupRole = await request.json();
3935

4036
const res = await addGroupRole(body, env);

src/utils/verifyAuthToken.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import jwt from "@tsndr/cloudflare-worker-jwt";
77
* @param env { env }: the ctx (context) which contains the secrets put in as wrangler secrets.
88
*/
99

10-
export async function verifyBot(authHeader: string, env: env) {
10+
export async function verifyAuthToken(authHeader: string, env: env) {
1111
const authToken = authHeader.split(" ")[1];
1212
await jwt.verify(authToken, env.RDS_SERVERLESS_PUBLIC_KEY, {
1313
algorithm: "RS256",

0 commit comments

Comments
 (0)