Category: Next.js, React and TypeScript

React use callback remembers outdated user rights

Read this guide in Polish

After changing the role, the button continues to perform the action according to the previous role saved in callback. Callback may close the old role value in close if it has not been declared in the depositors.

How to identify the source of the problem

Check whether the call is based on privileges in UI or in independent API validation. Review the use of callbacks table and determine when the current session object changes.

Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.

Repair steps

Consider the role you need to play in dependencies and enforce the current permissions on the server side for each operation. When changing the session, clear the user's cache data and cancel old queries and callbacks.

How to Test Solution

The new role is reflected in the interface and the server rejects actions after receiving permissions.

Security and restrictions

Do not base security on hiding the React status button or memory.