Skip to content

Commit 91726e2

Browse files
committed
adjust jsonata fn
1 parent 945111e commit 91726e2

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/components/Extensibility/helpers/jsonataWrapper.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { isEqual } from 'lodash';
44
import { getReadableTimestamp } from 'shared/components/ReadableCreationTimestamp/ReadableCreationTimestamp';
55
import { doesUserHavePermission } from 'state/navigation/filters/permissions';
66
import { permissionSetsSelector } from 'state/permissionSetsSelector';
7-
import { jwtDecode } from 'jwt-decode';
8-
import { AuthDataState, authDataState } from 'state/authDataAtom';
7+
import { useCheckSAPUser } from 'hooks/useCheckSAPUser';
98

109
/*
1110
Turns jsonata expressions like
@@ -95,17 +94,8 @@ export function jsonataWrapper(expression: string) {
9594
});
9695

9796
exp.registerFunction('isSAPuser', () => {
98-
const authData: AuthDataState = useRecoilValue(authDataState);
99-
try {
100-
if (authData && 'token' in authData) {
101-
const decoded = jwtDecode(authData?.token);
102-
return decoded?.sub?.includes('@sap.com');
103-
}
104-
} catch (error) {
105-
console.error('Error while checking if user is SAP user', error);
106-
return false;
107-
}
108-
return false;
97+
const isSAPUser = useCheckSAPUser();
98+
return isSAPUser;
10999
});
110100

111101
return exp;

0 commit comments

Comments
 (0)