@@ -26,6 +26,7 @@ import {
2626import { UserProfileDataBase } from "common/types/msGraphApi.js" ;
2727import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager" ;
2828import { DynamoDBClient } from "@aws-sdk/client-dynamodb" ;
29+ import { checkPaidMembershipFromTable } from "./membership.js" ;
2930
3031function validateGroupId ( groupId : string ) : boolean {
3132 const groupIdPattern = / ^ [ a - z A - Z 0 - 9 - ] + $ / ; // Adjust the pattern as needed
@@ -198,6 +199,7 @@ export async function resolveEmailToOid(
198199 * @param email - The email address of the user to add or remove.
199200 * @param group - The group ID to take action on.
200201 * @param action - Whether to add or remove the user from the group.
202+ * @param dynamoClient - DynamoDB client
201203 * @throws {EntraGroupError } If the group action fails.
202204 * @returns {Promise<boolean> } True if the action was successful.
203205 */
@@ -206,6 +208,7 @@ export async function modifyGroup(
206208 email : string ,
207209 group : string ,
208210 action : EntraGroupActions ,
211+ dynamoClient : DynamoDBClient ,
209212) : Promise < boolean > {
210213 email = email . toLowerCase ( ) . replace ( / \s / g, "" ) ;
211214 if ( ! email . endsWith ( "@illinois.edu" ) ) {
@@ -228,14 +231,8 @@ export async function modifyGroup(
228231 action === EntraGroupActions . ADD
229232 ) {
230233 const netId = email . split ( "@" ) [ 0 ] ;
231- const response = await fetch (
232- `https://membership.acm.illinois.edu/api/v1/checkMembership?netId=${ netId } ` ,
233- ) ;
234- const membershipStatus = ( await response . json ( ) ) as {
235- netId : string ;
236- isPaidMember : boolean ;
237- } ;
238- if ( ! membershipStatus [ "isPaidMember" ] ) {
234+ const isPaidMember = checkPaidMembershipFromTable ( netId , dynamoClient ) ; // we assume users have been provisioned into the table.
235+ if ( ! isPaidMember ) {
239236 throw new EntraGroupError ( {
240237 message : `${ netId } is not a paid member. This group requires that all members are paid members.` ,
241238 group,
0 commit comments