Example: User Management System
A complete admin section on web pages: invite, role, suspend and audit the people using your app, built on cluster accounts and a profiles storage.
An account signs in, a profile describes the person
Cluster user
Credentials, scopes, tokens. Created by an admin via User Access Management, the users API or function_user_create (create user).
Profile document
Your app's data about the person: display name, team, role, settings. Stored in a profiles storage keyed by the user's guid.
{
"_meta": {
"cms": 1780531200274,
"created": 1780531200,
"entity": 1,
"expiry": -1,
"guid": "b9ee6a631b24e78d1aa48aef0dc067fff7bfbacd24a56ef4ed1f08e537d48b6b",
"removed": 0,
"ums": 1782166695586,
"update_hash": "2c6a91e4f7530bd8146ae9c30fb5724d81ea3f06",
"updated": 1782166695
},
"display_name": "sami b",
"preferences": {
"digest": "weekly",
"theme": "dark"
},
"role": "manager",
"status": "active",
"team": "engineering",
"user_guid": "b9ee6a631b24e78d1aa48aef0dc067fff7bfbacd24a56ef4ed1f08e537d48b6bd02"
}Create profiles with the user's guid as guid_seed on function_create_document_from_mutations (create document). That gives one profile per user, and value_guid (generate guid) with the same seed gives you the profile's guid whenever you need to read it.
The lifecycle has four moves
Invite
The admin creates the cluster user with their scopes, then a flow creates the profile with
status: invitedand sends a welcome email (Email System Setup).First login
The member home page reads the profile. On
status: invitedits flow flips it toactiveand renders the onboarding checklist.Role changes
Update the profile's
rolefor app behavior and the user'scustom_scopesfor API and page gating. Keep both in one admin flow, so they never drift.Suspend
status: suspendedon the profile blocks app screens; removing the user's scopes blocks the APIs. Account deletion is the last resort, because suspending keeps the history.
Three pages cover the admin side
The directory
web_page (new web page) with event people and a custom scope people_admin, in a blueprint of its own. Search profiles with function_search (search), filtered by the page's query pin, into web_foreach (web for each) and web_render (web render). It is the list pattern from First CRUD App.
<main>
<h1>{{title}}</h1>
<form method="get">
<label>Team <input name="team" value="{{team}}"></label>
<label>Status <input name="status" value="{{status}}"></label>
<button type="submit">Filter</button>
</form>
<table>
<tbody id="people">{{{rows}}}</tbody>
</table>
</main><tr>
<td><a href="/people/{{_meta.guid}}">{{display_name}}</a></td>
<td>{{team}}</td>
<td>
<form data-action="set-role">
<input name="role" value="{{role}}" aria-label="Role" required>
<button type="submit" data-loading-text="Saving">Save</button>
</form>
</td>
<td>{{status}}</td>
<td>
{{if status != 'suspended'}}
<button type="button" data-action="suspend" data-confirm="Suspend {{display_name}}?">Suspend</button>
{{/if}}
</td>
</tr>Every action on a row works the same way. Its key pin is the guid of the profile the button sits in:
Update the profile
web_action(on web action)set-role, thenfunction_update_document_mutations(update document) withguidfromkeyand the newrole.Update the account
function_user_update(update user) with the profile'suser_guidand a mutation oncustom_scopes. This write is gated on the caller's own rights, so branch on itsconditionpin and answer a refusal withweb_errors(web form errors).Record it
Write the audit event; see below.
Replace the row
web_template(web template) with{{> person-row}}, the updated profile asdataand the guid askey, thenweb_replace(web replace). Only that row changes.
The detail page
web_page with event people/:guid: the profile fields in a form, scopes visible, and an activity summary with the last login from the cluster's user activity.
The self-service page
Members edit only their own profile. web_page with event my-profile and scope *loggedin, in a blueprint of its own. Take the guid from user_current (current user) through user_get_guid (get guid) and value_guid, and read with function_get_document (get document). See knowing who's calling. The save action takes the same guid from the session, never from the form.
Every admin action writes an event
- Invite, role change and suspend each write an event document: the actor from
user_current, the target, and the before and after values. It is the activity-log model from Storage Examples. - Review per-user history with a term query on
target_guid, sorted by_meta.created.
Next steps
User Roles Explained The scopes this example assigns. Building User Authentication The auth system underneath. Actions Row buttons, keys and in-place updates. Task Management App Assign work to these users.Frequently asked
What is the difference between a cluster user and a profile in RUAL?
The cluster user holds credentials, scopes and tokens, created by an admin through User Access Management or the users API. The profile document is your app's data about the person, such as display name, team, role and settings, stored in a profiles storage keyed by the user's guid.
How do I suspend a user in RUAL without deleting their history?
Set status: suspended on the profile to block app screens, and remove the user's scopes to block the APIs. Account deletion is the last resort, because suspending keeps the history.
How do I keep an audit trail of admin actions in RUAL?
Write an event document for every admin action, such as an invite, role change or suspend, with the actor from user_current, the target and the before and after values. Review per-user history with a term query on target_guid sorted by _meta.created.