# Signed-in users

Attach your users' name, email and picture to what they post, without asking for an email.

> **Plan:** Available on the Studio plan.

When people are signed in to your app, the [portal](https://getfrostbyte.dev/docs/feedback-portal-overview) and [widget](https://getfrostbyte.dev/docs/embed-widget) can post as them. Their name, email and picture go with each post.

**When to use it.** Most visitors skip an optional email field, so you can't reply or tell them when their request ships. Signing them in fills it in for them. Visitors who aren't signed in keep the optional email field.

**Turn it on with a Studio plan.** It's off until you switch on **Signed-in users** in Connect. While it's off, or below Studio, the portal ignores identity links, the widget ignores tokens and submissions ignore `identityToken`, so visitors see the email field. Posts still go through.

## Get your signing secret

1. Open **User Signals → Portal settings** and go to the **Connect** tab.
2. Switch on **Signed-in users**, then copy the secret with the copy button.
3. Store it on your server, for example as `FROSTBYTE_IDENTITY_SECRET`. Never put it in frontend code: anyone with it can post as any of your users.

![The Signed-in users section of Portal settings → Connect, switched on: the hidden signing secret with its copy button, and Show secret and Regenerate below it.](https://getfrostbyte.dev/images/docs/portal-signed-in-users.webp "Copy it without showing it, or choose Show secret to read it.")

## Sign a user's details

On your server, sign the signed-in user's details with the secret. The token is the details as base64url JSON, a dot, then their HMAC-SHA256 signature in base64url:

```js
import crypto from "node:crypto";

function frostbyteIdentity(user) {
  const body = Buffer.from(JSON.stringify({
    email: user.email,
    name: user.name,
    avatar: user.avatarUrl,
    exp: Math.floor(Date.now() / 1000) + 24 * 60 * 60,
  })).toString("base64url");
  const signature = crypto
    .createHmac("sha256", process.env.FROSTBYTE_IDENTITY_SECRET)
    .update(body)
    .digest("base64url");
  return `${body}.${signature}`;
}
```

| Field | Required | Notes |
|---|---|---|
| `email` | Yes | Lets you reply, and lets the person get the "shipped" email when their request is released. |
| `name` | No | Up to 100 characters. Shows as **Reported by** on the signal. |
| `avatar` | No | An `https://` image URL, shown beside the name. |
| `exp` | No | Unix time in seconds. After it, the token is refused. |

## Pass it to the portal or widget

| Where | How |
|---|---|
| Portal link | Add it after `#identity=`, such as `https://rollcall.getfrostbyte.dev/#identity=<token>`. The part after `#` never reaches a server, and the portal keeps it until the tab closes. |
| Widget | `FrostbyteWidget.identify({ token })`, or `data-user-token` on the script tag. See [Widget](https://getfrostbyte.dev/docs/embed-widget#tell-it-who-s-signed-in). |
| Your own form | Send it as `identityToken`. See [Submit from your app](https://getfrostbyte.dev/docs/submit-from-your-app#fields). |

## What visitors see

| Visitor | Sees |
|---|---|
| Signed in, on the portal or in the widget | Their picture, name and email in place of the email field. |
| Not signed in | The optional email field. |

## Things to note

- **Every post is checked.** A token that's been edited, has expired or was signed with another secret is refused, and the visitor is asked to refresh the page.
- **Regenerate to revoke.** **Regenerate** makes a new secret, and every token signed with the old one stops working until your app signs with the new one.
- **Names and emails stay private.** Only the project owner sees who sent a post. Titles and descriptions are public on your portal as usual.

## Related

- [Feedback Portal](https://getfrostbyte.dev/docs/feedback-portal-overview): what visitors can do on the portal.
- [Widget](https://getfrostbyte.dev/docs/embed-widget): a feedback button on your own site.
- [Submit from your app](https://getfrostbyte.dev/docs/submit-from-your-app): send requests from your own form.
- [Signals](https://getfrostbyte.dev/docs/signals): review what arrives.
