# Members — visitor accounts

> The official Members plugin — visitors sign up, verify their email, sign in, reset or change their password and have a My account page, plus a member menu block and members-only parts of pages

Source: https://anasaki.live/docs/en/store/plugin-members

The **Members** plugin (`members`) gives your site visitor accounts, separate from admin users — for online courses, communities, members-only content or letting customers see their own data.

Needs Anasaki Studio 2.2.2 or later.

## Ready-made pages

| Page | What it does |
| --- | --- |
| `/members/register` | Sign up (name, email, a password of at least 8 characters) |
| `/members/login` | Sign in |
| `/members/forgot` | Request a password reset link by email (valid 1 hour) |
| `/members/reset` | Set a new password from the email link |
| `/members/account` | My account: change the name, change the password, see the verification status and sign out |

## Confirmation and reset mails (1.4)

- They go through the **job queue**: signing up answers at once instead of waiting for the mail server; the mail leaves within seconds, and if the mail server is down it is tried again with growing pauses (up to 6 times). See **Site Code → Background jobs**.
- After signing up the form becomes **Check your e-mail**: the address, **Send the link again** (every 60 seconds) and **Sign in**.
- Signing in unconfirmed explains why, sends a fresh link by itself (at most every 10 minutes) and offers **Send the confirmation link again**.
- Members who joined while no confirmation was needed (e.g. before SMTP was set up) keep getting in after e-mail is switched on.
- The **Members** admin page has **Confirm** for members who never got the mail.
- **1.4.1** — the mails carry the site's name, a big button and a plain link · the confirmation link **signs the member in** and goes on to &#34;after sign-in&#34; · a used or expired reset link says so on opening, with **Get a new link**, and the reset page asks for the new password twice

## Change the password (1.3)

**My account** has a **Change password** form: the current password, then the new one (8+ characters) twice.

- This device stays signed in; every other device is signed out at once.
- 10 wrong current passwords in 15 minutes pause further tries for a while.
- Forgot the current one? Use **Reset it by e-mail** under the form.

An app that sends members to this page can add `?next=/path`: the page then shows **← Back** to that path (paths on the same site only).

Link these pages from your site's menu, or place the **Member menu** block in the header — before signing in it shows **Sign in / Sign up**, afterwards the member's name.

## Settings

| Setting | Meaning |
| --- | --- |
| Require email verification before signing in | Sends a verification link (valid 48 hours) — set up the site's **Email** first |
| Only accept email domains | e.g. `company.co.th` for an internal site |
| Remember sign-in (days) | Cookie lifetime (1–365, default 30) |
| After sign-in go to | A path on the site, e.g. `/members-area` (default: My account) |
| After verification go to | A path on the site (default: a confirmation page with a sign-in button) |

> [!NOTE]
> **1.1** — while the site cannot send email yet (no SMTP), new members are signed in at once without confirming their email, and the admin shows a notice to set up email.
>
> **1.3** — meanwhile **Forgot password** says plainly that the site cannot send e-mail yet and to contact the site owner (instead of claiming a link was sent). After signing up, the form is replaced by a **Sign in** button.

## Members-only content

In the designer, select a layer or frame and set **Condition → Show when**:

| Condition | Shown to |
| --- | --- |
| `visitor.is.member` | Signed-in members |
| `visitor.is.verified` | Members who verified their email |
| `!visitor` | Visitors who are not signed in (e.g. a sign-up prompt) |

Conditions are checked on the server, so hidden parts never reach the browser, and `{{visitor.name}}` shows the member's name in text.

## Managing members

The **Members** page (developer menu → plugin pages): search by email or name, see the last sign-in, **Suspend** (signs them out everywhere at once) or **Activate**, and **Export CSV** (no passwords).

## Security

- Passwords are stored with bcrypt; sessions and email links are stored as hashes only
- HttpOnly, SameSite=Lax cookies (and Secure on https)
- 10 wrong passwords in 15 minutes pause further attempts for a while
- Forms send JSON only, so other sites cannot submit them on a user's behalf (CSRF)

> [!WARNING]
> A site can have only one visitor identifier (`site.visitor`). If Site Code or another plugin already has one, Members cannot be activated until that one is removed.

## For developers

```ts
site.on('members.registered', (m) => log.info('new member', m.email));
site.route('GET /members-area/data', { access: ['group:member'] }, ({ visitor }) => ({ hello: visitor.name }));
site.filter('members.mail', (msg, { kind }) => ({ ...msg, subject: '[My site] ' + msg.subject }));
```
