Skip to content

Commit

Permalink
fix: require auth check in step settings
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Sep 6, 2024
1 parent 841990b commit 9c4581b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/react-ui/src/app/builder/piece-properties/form-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import {
function addAuthToPieceProps(
props: PiecePropertyMap,
auth: PieceAuthProperty | undefined,
requireAuth: boolean,
): PiecePropertyMap {
if (!requireAuth) {
return props;
}
return {
...props,
...spreadIfDefined('auth', auth),
Expand All @@ -53,6 +57,7 @@ function buildInputSchemaForStep(
addAuthToPieceProps(
piece.actions[actionNameOrTriggerName].props,
piece.auth,
piece.actions[actionNameOrTriggerName].requireAuth,
),
);
}
Expand Down Expand Up @@ -142,11 +147,18 @@ export const formUtils = {
}
case ActionType.PIECE: {
const actionName = selectedStep?.settings?.actionName;
const requireAuth = isNil(actionName)
? false
: piece?.actions?.[actionName]?.requireAuth ?? false;
const actionPropsWithoutAuth =
actionName !== undefined
? piece?.actions?.[actionName]?.props ?? {}
: {};
const props = addAuthToPieceProps(actionPropsWithoutAuth, piece?.auth);
const props = addAuthToPieceProps(
actionPropsWithoutAuth,
piece?.auth,
requireAuth,
);
const input = (selectedStep?.settings?.input ?? {}) as Record<
string,
unknown
Expand All @@ -170,7 +182,11 @@ export const formUtils = {
triggerName !== undefined
? piece?.triggers?.[triggerName]?.props ?? {}
: {};
const props = addAuthToPieceProps(triggerPropsWithoutAuth, piece?.auth);
const props = addAuthToPieceProps(
triggerPropsWithoutAuth,
piece?.auth,
true,
);
const input = (selectedStep?.settings?.input ?? {}) as Record<
string,
unknown
Expand Down

0 comments on commit 9c4581b

Please sign in to comment.