Skip to content
YasadDocs
Sign inGet started
Developer docs1 min read

Staff sign-in

Sign in with Yasad: staff use their own Yasad account in your app.

The business's people sign in to your app with their own Yasad account, so nobody shares a password and removing someone in Yasad ends their access. The owner turns on Staff sign-in on your app's page in Yasad and adds your return address (https://your-app/auth/callback; plain http only for localhost). Your key must be tied to that app, with the reader or operator role.

TypeScript
// /auth/start
const { url, pending } = await yasad.signIn.begin({ returnUrl: APP_URL + '/auth/callback' });
// keep `pending` in a short-lived HttpOnly cookie, then redirect to `url`
// /auth/callback?code=…&state=…
const who = await yasad.signIn.complete({ code, state, pending }); // { grantId, person, role, checkAfter }
// on every request
const still = await yasad.signIn.check(who.grantId); // current role, or 404 when access ended

Key your users on person.id. Check every page and every action yourself: in frameworks with nested layouts, a layout's check alone can be skipped. The staff dashboard starter is a complete example.

Type to search