Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Show hidden custom inputs only to authenticated sessions #90

Merged
merged 4 commits into from
Jul 1, 2024

Conversation

RubLo
Copy link

@RubLo RubLo commented Jun 28, 2024

Context/Change

Show custom inputs only to authenticated users, to prevent this scenario

Screenshot 2024-06-28 at 14 00 34

@RubLo RubLo changed the title [fix] Show custom inputs only to owner [fix] Show custom inputs only to authenticated sessions Jul 1, 2024
@RubLo RubLo marked this pull request as ready for review July 1, 2024 08:09
@RubLo RubLo requested a review from a team as a code owner July 1, 2024 08:09
tsogbadrakh-ch
tsogbadrakh-ch previously approved these changes Jul 1, 2024
Copy link

@tsogbadrakh-ch tsogbadrakh-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@haffla
Copy link
Collaborator

haffla commented Jul 1, 2024

We wanted to only hide the inputs of type "hidden" no?

@RubLo
Copy link
Author

RubLo commented Jul 1, 2024

We wanted to only hide the inputs of type "hidden" no?

Ah thanks, understood now what you meant for type hidden, will update it

@RubLo RubLo changed the title [fix] Show custom inputs only to authenticated sessions [fix] Show hidden custom inputs only to authenticated sessions Jul 1, 2024
@RubLo RubLo requested a review from haffla July 1, 2024 12:12
Comment on lines 504 to 508
const showHiddenInputs =
eventTypeCustomFound?.type === "HIDDEN" && sessionStatus === "authenticated";
if (!showHiddenInputs) {
return null;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, now you will only see hidden inputs when you are logged in and nothing else. Users that are not looked in will not see anything.

Shouldn't it be like

if (eventTypeCustomFound?.type === "HIDDEN" && sessionStatus !== "authenticated") {
  return null;
}

Copy link
Author

@RubLo RubLo Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 2 logics are equivalent, I do negate the result later with !showHiddenInputs.
I agree it's a bit hard to understand due to the !, but hideHiddenInputs was also weird naming.

I can remove the variable and do an inline check in the if statement if you prefer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditions are not equivalent. Imagine type is "TEXT". Then showHiddenInputs is false and you will not render anything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Monday. My head works slow. But yes definitely if you just inline it without leading negation, it's easier to understand.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if type is TEXT showHiddenInputs would be true and !showHiddenInputs evaluates as false

@haffla
Copy link
Collaborator

haffla commented Jul 1, 2024

Let's also add this change to the "Notificable Changes" section of the Confluence page.

@RubLo RubLo merged commit b15d37d into main Jul 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants