diff --git a/src/packages/shared-types/user.ts b/src/packages/shared-types/user.ts index 48922698a8..d9c6f262d1 100644 --- a/src/packages/shared-types/user.ts +++ b/src/packages/shared-types/user.ts @@ -15,6 +15,7 @@ export type CognitoUserAttributes = { given_name: string; family_name: string; email: string; + username: string; }; export const CMS_ROLES = [ diff --git a/src/packages/shared-utils/package-actions/rules.ts b/src/packages/shared-utils/package-actions/rules.ts index 22684988fd..9cfc05e17a 100644 --- a/src/packages/shared-utils/package-actions/rules.ts +++ b/src/packages/shared-utils/package-actions/rules.ts @@ -10,6 +10,8 @@ import { isStateUser, isCmsWriteUser } from "../user-helper"; const arIssueRai: ActionRule = { action: Action.ISSUE_RAI, check: (checker, user) => + // User is not an IDM user + !user.username.startsWith("IDM_") && checker.isInActivePendingStatus && // Doesn't have any RAIs (!checker.hasLatestRai || diff --git a/src/services/api/libs/auth/user.ts b/src/services/api/libs/auth/user.ts index fb1c8ede46..53f02e2633 100644 --- a/src/services/api/libs/auth/user.ts +++ b/src/services/api/libs/auth/user.ts @@ -33,6 +33,7 @@ function userAttrDict(cognitoUser: CognitoUserType): CognitoUserAttributes { } }); } + attributes["username"] = cognitoUser.Username; return attributes as CognitoUserAttributes; } diff --git a/src/services/ui/src/api/submissionService.test.ts b/src/services/ui/src/api/submissionService.test.ts index c9b56554e8..d117fd14f0 100644 --- a/src/services/ui/src/api/submissionService.test.ts +++ b/src/services/ui/src/api/submissionService.test.ts @@ -39,6 +39,7 @@ const mockGeorge: OneMacUser = { family_name: "Harrison", "custom:state": "VA,OH,SC,CO,GA,MD", email: "george@example.com", + username: "IDM_a853eb41-f5fc-48af-911d-4f478e4da3a2 ", }, }; diff --git a/src/services/ui/src/api/useGetUser.ts b/src/services/ui/src/api/useGetUser.ts index 0fea8696e1..9c5d08a921 100644 --- a/src/services/ui/src/api/useGetUser.ts +++ b/src/services/ui/src/api/useGetUser.ts @@ -3,7 +3,10 @@ import { Auth } from "aws-amplify"; import { CognitoUserAttributes } from "shared-types"; import { isCmsUser } from "shared-utils"; -export type OneMacUser = { isCms?: boolean, user: CognitoUserAttributes | null } +export type OneMacUser = { + isCms?: boolean; + user: CognitoUserAttributes | null; +}; export const getUser = async (): Promise => { try { @@ -17,6 +20,7 @@ export const getUser = async (): Promise => { if (!user["custom:cms-roles"]) { user["custom:cms-roles"] = ""; } + user["username"] = authenticatedUser.username; const isCms = isCmsUser(user); return { user, isCms } satisfies OneMacUser;