Skip to content

Commit 49f2ddd

Browse files
authored
Re-add paid member check on membership checkout sessions (#421)
1 parent a30528e commit 49f2ddd

File tree

1 file changed

+7
-41
lines changed

1 file changed

+7
-41
lines changed

src/api/routes/v2/membership.ts

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,13 @@ import {
2525
} from "api/components/index.js";
2626
import { verifyUiucAccessToken, getHashedUserUin } from "api/functions/uin.js";
2727
import { getKey, setKey } from "api/functions/redisCache.js";
28-
import { getEntraIdToken } from "api/functions/entraId.js";
29-
import { genericConfig, roleArns } from "common/config.js";
30-
import { getRoleCredentials } from "api/functions/sts.js";
31-
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
32-
import { BatchGetItemCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";
28+
import { genericConfig } from "common/config.js";
29+
import { BatchGetItemCommand } from "@aws-sdk/client-dynamodb";
3330
import { AppRoles } from "common/roles.js";
3431
import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
3532
import { syncFullProfile } from "api/functions/sync.js";
3633

3734
const membershipV2Plugin: FastifyPluginAsync = async (fastify, _options) => {
38-
const getAuthorizedClients = async () => {
39-
if (roleArns.Entra) {
40-
fastify.log.info(
41-
`Attempting to assume Entra role ${roleArns.Entra} to get the Entra token...`,
42-
);
43-
const credentials = await getRoleCredentials(roleArns.Entra);
44-
const clients = {
45-
smClient: new SecretsManagerClient({
46-
region: genericConfig.AwsRegion,
47-
credentials,
48-
}),
49-
dynamoClient: new DynamoDBClient({
50-
region: genericConfig.AwsRegion,
51-
credentials,
52-
}),
53-
redisClient: fastify.redisClient,
54-
};
55-
fastify.log.info(
56-
`Assumed Entra role ${roleArns.Entra} to get the Entra token.`,
57-
);
58-
return clients;
59-
}
60-
fastify.log.debug(
61-
"Did not assume Entra role as no env variable was present",
62-
);
63-
return {
64-
smClient: fastify.secretsManagerClient,
65-
dynamoClient: fastify.dynamoClient,
66-
redisClient: fastify.redisClient,
67-
};
68-
};
6935
const limitedRoutes: FastifyPluginAsync = async (fastify) => {
7036
await fastify.register(rateLimiter, {
7137
limit: 15,
@@ -150,11 +116,11 @@ const membershipV2Plugin: FastifyPluginAsync = async (fastify, _options) => {
150116
throw new InternalServerError({});
151117
}
152118
request.log.debug("Saved user hashed UIN!");
153-
// if (isPaidMember) {
154-
// throw new ValidationError({
155-
// message: `${upn} is already a paid member.`,
156-
// });
157-
// }
119+
if (isPaidMember) {
120+
throw new ValidationError({
121+
message: `${upn} is already a paid member.`,
122+
});
123+
}
158124
return reply.status(200).send(
159125
await createCheckoutSessionWithCustomer({
160126
successUrl: "https://acm.illinois.edu/paid",

0 commit comments

Comments
 (0)