---
url: /saas-starter/v0.9.0/upgrading/v0.8.0.md
---
# Upgrading to v0.8.0

v0.8.0 is the account security release: two-factor authentication, security emails, sessions in
Settings, asking for the password again before risky changes, and an optional breached-password
check. Apps without accounts (`--Auth none`) change very little.

Start from v0.7.0. Make and apply the patch as [How to upgrade](./index.md) describes:

```bash
./upgrade-patch.sh 0.7.0 0.8.0 MyApp --Auth saas     # your name and options
git apply -3 upgrade.patch
```

How big the patch is depends on the options:

| `--Auth` | Files changed |
|---|---|
| `saas` | about 112 (115 with EF Core) |
| `identity` | about 90 |
| `none` | 6: docs and package versions |

## Before you deploy

### Decide on the new settings

| Setting | Default | What to do |
|---|---|---|
| `Accounts:AskForProductNews` | `true` | Sign-up shows an unticked "Send me product news" box. Turn it off if the app won't send product news. |
| `Accounts:RequireTwoFactorForAdmins` | `false` | Turn on to keep the back office for admins with two-factor authentication. Admins without it are sent to Settings to set it up. |
| `Accounts:RejectBreachedPasswords` | `false` | Turn on to refuse new passwords known from data breaches. It calls Have I Been Pwned's range API, sending five characters of the password's SHA-1 hash. |
| `Accounts:TwoFactorIssuer` | the app's name | The name authenticator apps show next to the code. |

### Expect more email

People are now emailed when:

* their password is changed or reset, or their email changes (at the old address);
* two-factor authentication is turned on or off, or recovery codes are replaced or used;
* a passkey or a Google or GitHub sign-in is added or removed;
* the account is locked after too many wrong passwords or codes;
* someone signs in from a device that hasn't signed in before.

These are always sent. Check that your email provider's sending limits allow for them. The text is in
`Identity/Email/SecurityNotices.cs`.

### EF Core: two migrations

`AddSessions` (sessions on refresh tokens) and, with organisations, `AddOrganisationTwoFactor`.
They're applied at startup. If you added migrations of your own, see the
[EF Core note](./index.md#_4-check-it) on the model snapshot.

With Marten, the user document gains `AuthenticatorKey` and `RecoveryCodes`, and organisation
members a two-factor field: nothing to migrate.

## If you changed the template's code

The compiler finds most of these. They matter if your code calls the account endpoints directly,
replaces the template's stores, or has another client (a mobile app, say) signing in.

* **Endpoints that change sign-in details return `(result, OutgoingMessages)`** with a
  `SendSecurityNotice`: changing and resetting the password, confirming an email change, adding or
  removing a passkey, removing a Google or GitHub sign-in, the two-factor endpoints, and the
  Google/GitHub callback. **Login, the two-factor step and passkey login** do too, for the
  new-device email. Read the result from the tuple's first item.
* **Logging in can answer 403 with `"reason": "TwoFactorRequired"`** and a `twoFactorTicket`.
  Clients other than the bundled one then send the ticket and a code to
  `POST /api/auth/two-factor` for the tokens. See
  [Sign in from a mobile or desktop app](../guide/how-to/sign-in-from-a-mobile-app.md).
* **Changing the email needs the current password** (`UpdateProfileRequest.CurrentPassword`, and
  `TwoFactorCode` with two-factor on), and **deleting the account needs a code** with two-factor
  on (`DeleteAccountRequest.TwoFactorCode`; `Password` is now optional, for accounts without one).
  `GET /api/auth/me` has `hasPassword` and `twoFactorEnabled`, so a client knows what to ask for.
* **`UserManager<ApplicationUser>` is now `ApplicationUserManager`**, registered in its place. Code
  that asks for `UserManager<ApplicationUser>` gets it unchanged. If your app has its own user
  manager, derive it from `ApplicationUserManager` instead.
* **`IRefreshTokenStore` has `ListActiveForUserAsync` and `RevokeSessionsAsync`**, and with
  organisations `IOrganisationStore.CanWorkInAsync` takes whether the user has two-factor. Add
  them to your own implementations.
* **Access tokens carry a `sid` claim** (the session) and, with organisations, a `tfa` claim.
  `JwtTokenService.CreateAccessToken` takes them.
* **`TokenIssuer` can leave the Admin role out** of a token when
  `Accounts:RequireTwoFactorForAdmins` is on.
* **`RegisterRequest` has `ProductNews`**, and `AuthOptionsResponse` says whether to ask.
* **A new client dependency, `uqr`**, draws the QR code: run `npm install` in `src/Client`.

## Check it works

After the checks in [How to upgrade](./index.md#_4-check-it):

1. Sign in, open **Settings → Two-factor authentication**, set it up with an authenticator app, and
   save the recovery codes.
2. Sign out and in again: you're asked for a code.
3. Open **Settings → Sessions**: this device is listed.
4. Check Mailpit (http://localhost:8025) for the "Two-factor authentication is on" email.

The [full release notes](../releases/v0.8.0.md) list everything new.
