# Update your settings

## Update your settings

Use **Your Settings** to change the personal details held on your profile: your profile-picture
URL, username, bio, email address, and optional password. After a successful update, the app
takes you to the profile for the submitted username.

| If you need to… | Go to |
|---|---|
| See what each setting does | [Review the settings fields](#review-the-settings-fields) |
| Change your personal details | [Update your settings](#update-your-settings-1) |
| Handle an optional password or sign-in branch | [Handle optional password and sign-in branches](#handle-optional-password-and-sign-in-branches) |
| Resolve an update error | [When an update goes wrong](#when-an-update-goes-wrong) |
| Continue to your profile after saving | [View a profile](doc:view-a-profile) |
| Read the general error messages | [General error messages](doc:general-error-messages) |

## Before you start

You must be signed in before you can open the settings screen. The form loads your current
username, email, bio, and profile-picture URL when the screen opens. Your password is not
loaded into the form.

**Prerequisites**

- Have an authenticated account.
- Have the new values ready for any details you want to change.

If you open the settings route while signed out, the app sends you to the sign-in route.

## Open Your Settings

### Open the settings screen

**Prerequisites**

- You are signed in.

**Steps**

1. Open `/settings`.

**Result:** The **Your Settings** screen opens with the settings form.

## Review the settings fields

The settings form contains five personal details that you can review before submitting a change.
The prompts appear inside the fields rather than as separate visible field labels.

| Field | What to enter |
|---|---|
| **URL of profile picture** | The URL for the profile picture you want to use. |
| **Your username** | The username you want associated with the profile. |
| **Short bio about you** | A short description about you. |
| **Email** | Your email address. |
| **Password** | A new password when you want to change it. |

None of the five fields has a required marker. **Password** starts empty rather than being copied
from your current account.

## Update your settings

Change the details you want to store, then submit the form. The update sends the username, email,
bio, and profile-picture URL. It sends a password only when you enter one.

**Prerequisites**

- You are signed in and the settings form is open.

**Steps**

1. Enter the new value in the relevant field.
2. Choose the password handling that matches your change in **Password**:

   | If you need to… | In **Password** |
   |---|---|
   | Keep your current password | Leave the field empty. |
   | Change your password | Enter the new value. |

3. Select **Update Settings**.

**Result:** The app clears the current error list and routes you to the profile for the submitted
username.

## Handle optional password and sign-in branches

The **Password** choice determines whether a password is included in the update. Sign-in controls
whether the settings screen opens.

**Prerequisites**

- Decide whether you are changing the password.

**Steps**

1. Choose the path that matches your situation:

   | If you need to… | Do this |
   |---|---|
   | Keep your current password | Leave **Password** empty, then continue with the other settings. |
   | Change your password | Enter the new value in **Password**, then continue with the other settings. |
   | Open settings while signed out | Sign in when the app sends you to the sign-in route. |

**Result:** An empty **Password** is omitted from the update, an entered password is included, and
a signed-out attempt is sent to sign-in.

## When an update goes wrong

The error list displays the values returned when an update produces errors. A network failure uses
the message `Unable to connect to the server`.

**Prerequisites**

- The settings form is open.
- You have entered the values you want to submit.

**Steps**

1. Select **Update Settings**.
2. Read the message shown in the error list:

   | Message | Where it appears |
   |---|---|
   | A server-provided error value | The error list. |
   | `Unable to connect to the server` | The error list. |

**Result:** The error list displays the server-provided error value or
`Unable to connect to the server`.

## Leave Settings

After you submit a successful update, the app takes you to the profile for the submitted
username. You can also sign out from the settings screen.

**Prerequisites**

- The settings screen is open.

**Steps**

1. Choose the path that matches what you want to do:

   | If you need to… | Select |
   |---|---|
   | Continue with the updated profile | Select **Update Settings**, then continue from the submitted username's profile. |
   | End your signed-in session | Select **Or click here to logout.** |

**Result:** A successful update takes you to the submitted username's profile. Logging out clears
the signed-in session and takes you to home.
