The Daily WTF
Follow
CodeSOD: Check and Check
The provided React code snippet displays admin options based on user authorization.
It uses a conditional rendering approach with the logical AND operator.
If a user is an administrator or has permission to see results, an "Admin Actions" header is rendered.
Following the header, a "Show Results" button is also conditionally displayed.
This button appears only if the user meets the same authorization criteria: being an admin or able to see results.
The author likens this implementation to a "belts and braces" approach, suggesting redundancy.
They believe this duplicated condition does not enhance security or functionality.
The code aims to restrict access to sensitive administrative features.
However, the repeated checks are flagged as unnecessary or inefficient.
The core idea is authorized users see admin-related content, but the implementation is questioned for its repetition.