Flows category icon
App Builder
Advanced

Role-Based Access Control

Add real roles and permissions: enforced on backend endpoints and reflected honestly in the UI.

6 steps19 verify checks60-120 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/6 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
I am adding roles (e.g. admin, member, viewer) so different users have different capabilities in my app.

GOAL:
Implement roles stored per user, enforced on every protected endpoint, and reflected in the UI.

REQUIREMENTS:
- Role field on the user model with defined role set
- Permission matrix: which role can do which action
- Backend enforcement (403) on every protected endpoint
- UI adaptation: hidden/disabled controls per role
- An admin surface to change user roles

CONSTRAINTS:
- Hiding buttons is not enforcement - the backend must reject
- Never trust a role claim from the client
- Protect against self-demotion of the last admin

DEFINITION OF DONE:
- Each role sees the correct UI
- Forbidden API calls return 403 regardless of UI
- Role changes take effect without re-registration
- The last admin cannot remove their own admin role

COMMON FAILURES TO AVOID:
- Role checks only in the frontend
- Role read from localStorage where users can edit it
- Admin endpoints open to any authenticated user
- Role changes requiring logout/login to apply

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More App Builder flows that share ground with this one.

Flows category icon
App Builder
Generated

Add Team Invites to a SaaS App

Build a real team invitation system for a SaaS app, including invite creation, email/share flow, acceptance, membership creation, role assignment, validation, and end-to-end testing.

01Audit Existing Team, User, and Auth Models
02Add Invitation Data Model and Migration
03Implement Secure Invite Creation API

+7 more steps to Done

Best forbuilders who have shipped a basic app before

10 steps60-120 minutesIntermediate
Flows category icon
App Builder

Admin Dashboard

Build a real admin dashboard with live data tables, stats, filters, and actions that actually mutate data.

01Define admin scope and data
02Build admin layout and access control
03Implement real stats cards

+3 more steps to Done

Best forbuilders who have shipped a basic app before

6 steps45-90 minutesIntermediate
Flows category icon
App Builder
Generated

Add Real-Time Presence Indicators to a Chat App with WebSockets

A step-by-step flow for implementing real-time online, offline, and typing presence in a chat app using WebSockets, including backend presence tracking, frontend updates, reconnect handling, and verification.

01Inspect the existing chat architecture and choose presence data flow
02Define the presence event contract and server-side state model
03Implement authenticated WebSocket connection handling on the server

+7 more steps to Done

Best forbuilders who have shipped a basic app before

10 steps60-120 minutesIntermediate

Made with Emergent