Roles are numbers in site.yaml. A page with access: member can be read by members and by anyone with a higher role. Anonymous visitors get 401, signed-in visitors with too low a role get 403.
Passwords are stored as Argon2id hashes in the database. There is no sign-up form and no account page: the admin is created with alcove -seed-admin, and other accounts come from a migration or the command line. Sign-in is an alcove with a form that posts to the built-in _login address.
After signing in the visitor goes back to the page the form was on, or to next in the form. A page named 401 or 403 is shown in place of the plain answer, at the refused address, so its sign-in form returns there.
Templates can read the visitor: {{ user.name }}, {{ user.role }}, {{ user.signed_in }}, user in tile conditions and :user in a query. Such an alcove is live, see Caching. The footer of every page here uses one to show who is signed in.
This site has a public guest account with the member role, so you can try it.
Live result This page is a static file, built once.
Sign in as the guest member, then open the members' shelf.
The members' shelfGives 401 until you sign in, with a sign-in form that brings you back.
Source the files behind the result above
content/site.yaml (excerpt)
roles:
member: 1
admin: 2
content/pages/docs-access-members.yaml
slug: docs/access/members
lang: en
title: The members' shelf
alcove: house
access: member
meta:
description: A page only signed-in members can read.
nav: docs
nooks:
main:
- alcove: membershead
- alcove: vault
- alcove: signout
content/alcoves/demo_guestsignin/alcove.yaml
fields:
- name: username
type: text
- name: password
type: text
form:
to: _login
fields: [username, password]
next: /docs/access/members/
content/pages/401.yaml
slug: "401"
lang: en
title: Members only
alcove: house
meta:
description: Sign in to read this page.
nav: none
nooks:
main:
- alcove: door401