Managing users from your website
The admin calls a website can make to list users, invite people, change roles and disable accounts, and the profile calls every signed-in user has.
On this page
For a team tool or a CRM the builder makes a Team page around these calls. Each admin call refuses anyone who is not a signed-in admin, and the platform never allows a change that would leave the website with no active admin.
import { auth } from "@praxivara/sdk";
const users = await auth.listUsers(); // [{ id, email, display_name, role, status, created_date, last_login_at }]
await auth.inviteUser({ email, role: "user" }); // emails a link to join
await auth.setUserRole(id, "admin"); // "admin" | "user"
await auth.setUserStatus(id, "disabled"); // "active" | "disabled"The invite email carries a link to set a password or, when only Google sign-in is on, a link to continue with Google. Invites need the website to be published and not private. Setting someone who is waiting for approval to active lets them in.
What every signed-in user can do
const me = await auth.me(); // null when signed out
await auth.updateMyUserData({ display_name: "Ana", data: { plan: "pro" } });
auth.logout();data is a small free-form object for things your website wants to remember about the person: preferences, a plan name, an onboarding step.
Sign-in calls
await auth.register(email, password, displayName);
await auth.login(email, password);
auth.loginWithGoogle({ returnTo: "/dashboard" });
const result = await auth.googleSignInResult(); // after a Google round-trip
await auth.forgotPassword(email);
await auth.resetPassword(token, newPassword);
const { email: emailOn, google: googleOn } = await auth.methods();Reading the session in a page
Pages read the session through the platform's session helpers rather than calling auth.me() themselves, so the whole website loads it once:
import { useSession, RequireAuth } from "@/lib/session.jsx";
function Dashboard() {
const { user, isAdmin } = useSession();
return <h1>Welcome back, {user.display_name}</h1>;
}
<Route path="/dashboard" element={<RequireAuth><Dashboard /></RequireAuth>} />
<Route path="/admin" element={<RequireAuth roles="admin"><Admin /></RequireAuth>} />What went wrong? Pick any that apply.
That didn't send. Try again in a moment.