StableGuide
Role-based navigation
Goal: after signing in, staff land on the dashboard while customers land on their portal; a shared button sends each role to the right place.
Role-based navigation
Goal: after signing in, staff land on the dashboard while customers land on their portal; a shared button sends each role to the right place.
Data needed
- Authentication turned on (Users → Sign-in) and at least two roles in use, for example the built-in Staff and Customer.
- Two pages: Dashboard (access: Specific roles → Staff) and My requests (access: Signed-in users).
Step 1 — a button that navigates by role
- Select the button (for example Continue on the home page) and open its Actions tab.
- Under onClick, click Add action → If / else (group Logic).
- Set the If condition: Current user › role is
Staff. The role value is the role's name as shown in Users → Roles & permissions. - In the Then list add Go to page → Dashboard.
- In the Else list add Go to page → My requests.
- Preview with Preview as set to Staff, then to Customer, and click the button.
Example
onClick
If Current user › role is "Staff"
Then Go to page → Dashboard
Else Go to page → My requestsStep 2 — land on the right page after sign-in
There is one After sign-in page per app (Users → Sign-in → After sign-in, go to), and the built-in /login screen always uses it (or returns the visitor to the protected page they originally asked for). To branch by role after sign-in:
- Create a public page Welcome and make it the After sign-in page.
- Click the empty canvas of Welcome and, under When the page opens, add the same If / else with Go to page actions as above. Visitors are redirected the moment the page loads.
If you use the Login Form component on your own page instead of /login, you can set its After sign-in go to page per form, or add the If / else to its onSuccess event.
Step 3 — keep menus and pages consistent
- Pages a role may not open are hidden from the navigation automatically, and opening them directly shows Access denied (or sends signed-out visitors to sign-in). Configure this in Users → Roles & permissions → Page access.
- To hide a single button or section from a role, use its Permissions tab; to merely show or hide based on a value, use Visibility.
Resulting behaviour
- The button sends staff to the dashboard and everyone else to the portal, with no flicker: the condition is evaluated in the browser from the signed-in user's role.
- Role names are compared case-insensitively.
- If the visitor is not signed in, Current user › role is
Public, so the Else branch runs; use a nested If / else on Current user › isAuthenticated to send them to sign-in with the Sign in action.
Variations
- More than two roles: nest an If / else in the Else list, or compare Current user › role with is one of (
Staff, Admin). - Admins see everything: full-access roles (Owner, Admin) can open every page; route them like staff.
- Storyboard view: the Storyboard shows these conditional edges with their condition labels, and the by role layout groups pages by who can reach them (see Role-based navigation in the Storyboard).
Common mistakes
- Comparing with the role id (
role_staff) instead of the name (Staff): the data picker's Current user › role holds the name. - Renaming a role after building conditions: update the conditions too.
- Relying on navigation to protect data: a customer who guesses the dashboard URL is stopped by page access and entity permissions, not by the If / else. See Security model.