Take a look around.
ReactJS / Staff tools

React staff roles: hiding a button is not a permission check

By Lan T.6 min read

Use the interface to show people what they can do, and have the server check whether each protected request is allowed. Agree on the roles, records and actions first. Then test allowed and denied requests directly, including a role change while someone is still signed in.

Diagram: roles and tasks, then allowed actions, then server enforcement, then review the requests.
Visible controls help people understand their role; server checks protect the records.Open the full diagram ↗

Start with the work each person needs to do

“Admin access” can mean too many things. Does this person need to find a member, read payment history, correct a record or retry a failed access update? Write those tasks down before choosing role names.

A support colleague may need to explain a membership without changing it. Someone handling access recovery may need a small set of changes with a recorded reason. A clear division helps people do their jobs without giving everyone every control.

Include which records a person may access. Permission to view a member does not automatically mean permission to view every member, organisation or file in another product.

Make the roles-and-actions table specific

RoleHarbor has three staff roles. Viewers can read permitted records. Admins handle day-to-day membership operations. Owners also manage business and provider settings, package-to-role mapping and room permissions. Private owners manage the staff team. Shared demo accounts keep team and security settings fixed. A signed-in account without an approved staff role cannot use the staff API.

Those names describe this product’s policy. Your app may need a narrower support role, approval for refunds or separate access by organisation. An export is another action to decide explicitly; being able to read a screen should not silently grant a bulk download.

Task in RoleHarborViewerAdminOwner
Read a permitted member recordAllowedAllowedAllowed
Change membership accessDeniedAllowed, with a reasonAllowed, with a reason
Create or edit membership packagesDeniedAllowed within plan rulesAllowed within plan rules
Retry eligible failed workDeniedAllowedAllowed
Map package roles or change room accessDeniedDeniedAllowed
Configure Stripe or Discord credentialsDeniedDeniedAllowed, with password confirmation
Invite, change or revoke staffDeniedDeniedPrivate owner only; the shared demo Owner is refused
Restore saved demo connectionsDeniedDeniedAllowed with password; connection settings only

Help people understand what their role allows

A read-only screen should make that clear before someone spends time filling in a form they cannot submit. Depending on the task, remove an irrelevant control or keep it disabled with a short explanation and a useful next step.

Treat loading, a failed request and a permission refusal as different states. If access changes while a form is open, explain what happened and preserve non-sensitive work where it is safe to do so. Avoid a success message before the server has accepted the change.

The interface is there to guide the person using it. A hidden button or a React route guard cannot decide what a direct request to the API is allowed to do.

Check access where the data is read or changed

For a protected request, the server needs a valid session and permission for the requested action and record. If the rules do not grant access, refuse it. Keep that decision consistent across the staff routes rather than relying on each screen to remember it.

RoleHarbor’s staff API checks the database-backed session and the stored staff role before handling the request. A viewer’s change request is rejected before it changes membership state. Owner and admin changes record the acting account in the history.

OWASP recommends checking permission on every request, denying access by default and testing the intended rules. Treat these as design and review requirements across the app.

An activity entry made with a shared demo account identifies that account, not a particular visitor. Private staff accounts are needed when a business must attribute changes to an individual teammate.

Account for a role change and an expired session

Someone can lose a role while their browser tab is still open. The old screen may still display controls, but the next protected request must use the permissions that apply now. The same applies when an account is removed from the staff list.

An expired session usually needs a sign-in step. A person who is signed in but lacks permission needs a different explanation. Repeatedly asking that person to sign in again will not give them a missing permission.

In RoleHarbor’s API, a missing or expired session returns a sign-in-required response. A recognised session without the required staff permission returns a forbidden response. The interface can translate those outcomes into a useful message.

Private staff can enable authenticator MFA and retain recovery codes for their account. When MFA is enabled, knowing the password alone does not open protected administration. The public demo accounts cannot change passwords or MFA. Their shared password is for trying the workspace, not a pattern for a business’s private staff accounts.

Review the request as well as the screen

Try the same protected action as a viewer, an authorised editor and an account with no staff access. Inspect the stored result after each request. A refusal is incomplete if the response says “denied” but the record, queued work or history has already changed.

Include an allowed case. A check that rejects everyone can look safe while preventing the team from doing its work. Review the resulting change and its recorded actor, then repeat a denied request after changing the role on the existing session.

ScenarioWhat to check
No session or an invalid sessionProtected records and changes are refused.
Signed in without staff accessStaff data stays unavailable.
Viewer reads a permitted recordThe expected record can be read.
Viewer sends a change directlyThe change is refused and protected state is unchanged.
Owner or admin makes a permitted changeThe intended state changes and the actor is recorded.
Role is reduced or staff access is removedThe existing session cannot keep the old privileges.
Session expiresProtected access stops and the interface offers sign-in.

Agree on the rules before asking an agent to build them

The product owner decides which tasks each role may perform and whether any actions need approval. The developer maps those decisions to the server routes and the interface. An agent can trace the paths, draft the matrix and run the agreed checks.

The developer reviews the denied-request tests and the resulting records, not just the test count. The product owner tries the workflow as the intended staff role. If an additional security reviewer is needed, name that responsibility in the scope rather than assuming an agent’s summary supplies it.

Start with one staff workflow

Bring the roles you have, the task each person needs to finish and the records involved. We can map one workflow, agree on the permitted changes and review the screen and API behavior together.

Explore the working system

Try RoleHarbor for yourself.

RoleHarbor serves one business and one Discord server. Try the member journey or sign in as Owner, Administrator or Viewer. The demo uses Stripe test mode; no real charges are collected. Discord uses the configured demo server.

How to sign in and restore the connections
  1. Open the staff demo. The sign-in page lists the three available accounts.
  2. Choose Owner, Administrator or Viewer to fill in the email and password. Start with Viewer if you want to look around.
  3. Select Sign in. Use the workspace navigation to explore members, plans, billing and operations.
Owner
demo.owner@beemvp.comBusiness and provider settings, package-to-role mapping, room access and membership operations.
Administrator
demo.admin@beemvp.comDay-to-day membership operations, packages, billing and eligible failed-work retries.
Viewer
demo.viewer@beemvp.comRead-only access to the workspace. Changes are refused by the server.

Shared password: RoleHarbor@Demo

These public accounts keep fixed sign-in details. They cannot change staff accounts, passwords or MFA. Private staff accounts retain the full team and security controls.

Restore the default connections

Sign in as Owner, open Connections and choose Reset demo. Enter the shared password, then select Restore default connections.

This restores the saved Stripe test keys and Discord connection settings. It keeps members, payments, plans and activity. It does not undo Discord room changes, reverse payments or reset the whole workspace.

This is a shared workspace, so other visitors may change its records. Use test information when trying an editable role.

Further reading & related work

Product examples and references for the decisions in this note.

Have a similar piece of work?

Let’s map the roles for your first workflow.

Tell me what you’re working on ↗

Keep reading