> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/how-the-apps-work/screens/staff/sign-in.md).

# Log in

{% hint style="info" %}
Draft, written by an agent and not yet checked by a person ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). Platforms: web. [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/screens/staff/sign-in.md).
{% endhint %}

Staff sign in to the admin app with a username and password. The app keeps a session only for users marked as Snapfix staff, and that check runs in the browser.

* **Where:** admin app `/login`. Every other page sends a signed-out user here, except the error page `/error-page/:code`, which has no guard (webadmin\_angular @ db972390b8, `src/app/app-routing.module.ts:132`). The page is not in the side menu.
* **Who:** signed-out users. A signed-in user who opens `/login` goes to `/home`.
* **Feature:** [Staff admin app](https://docs.snapfix.com/product/features/staff/staff-admin.md)

## Layout

One form with no title. The side menu stays hidden until a session exists. Outside production, "This is TEST Environment." shows above every page of the app, this one included (`src/app/app.component.html:27-29`).

1. "Username", with a user icon.
2. "Password", with a lock icon and an eye button that shows or hides the text.
3. "Log in", with a login icon.

## Inputs

| Field    | Type                                    | Required | Default | Rules and messages                                              |
| -------- | --------------------------------------- | -------- | ------- | --------------------------------------------------------------- |
| Username | Text                                    | Yes      | Empty   | Under the field when it is empty: "Please input your username". |
| Password | Password; the eye button shows the text | Yes      | Empty   | Under the field when it is empty: "Please input your password". |

Pressing "Log in" with either field empty shows the toast "Username and password are required." and sends nothing (`src/app/pages/login/login.component.ts:40`). The app checks nothing else; authpy's own rules show as toasts (see [States](#states)).

## Actions

| Action                    | Who              | What happens                                                                                                                                                                                                                                                                                                                                                                                                                                                         | API                                                                                                                                    |
| ------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| Log in                    | Signed-out users | Sends the username and password as form data, with the Basic login built into the app. The button shows a spinner, and further presses are ignored until the answer comes. An answer that is not a success shows its message as a toast. A user whose `fSnapfixWebAdminUser` is not 1 gets "The username or password is invalid." and nothing is kept, although authpy has issued tokens. Otherwise the tokens and the profile are stored and the app opens `/home`. | `POST /login` (authpy), in the [Auth API](https://docs.snapfix.com/engineering-reference/api/auth.md), which has no section for it yet |
| Show or hide the password | Signed-out users | Switches the password between hidden and plain text.                                                                                                                                                                                                                                                                                                                                                                                                                 | None                                                                                                                                   |
| "Log Out" (side menu)     | Signed-in users  | Clears the session and opens this page.                                                                                                                                                                                                                                                                                                                                                                                                                              | None                                                                                                                                   |

```mermaid
flowchart TD
  A[Signed-out user opens /login] --> B[Enter username and password]
  B -->|a field is empty| T["Username and password are required."]
  B --> C[POST /login with the built-in Basic login]
  C -->|result false| D[Toast with authpy's message]
  C -->|tokens and profile| E{fSnapfixWebAdminUser is 1?}
  E -->|no| F["The username or password is invalid."]
  E -->|yes| G[Session in the tab's session storage]
  G --> H["/home"]
```

**Session.** The access token, the refresh token and the profile sit in the browser's session storage, so the session ends when the tab closes, and any script that runs in the page can read it. When a call answers 401, the app asks authpy's `POST /refresh` for a new access token, using the refresh token, and repeats the call. If the refresh answers 401 too, the app clears the session and opens `/login` (`src/app/services/auth/auth-interceptor/auth.interceptor.ts:44-79`).

## States

* **Loading:** "Log in" shows a spinner while the request runs.
* **Empty:** not applicable.
* **Error:** authpy answers a refused sign-in with HTTP 200, `result` `false` and a message, which shows as a toast: for example "invalid credentials" (no live user with that username), "Incorrect password", or "The password must be at least six characters long" (authpy @ 5d5758661c, `app.py:411-413`, `:445-448`, `model/feature_user_auth.py:133`, `:229`). An answer without a message shows "Internal server error". HTTP 401 and 409 answers show nothing (`src/app/services/http/http.service.ts:73-79`).
* **No permission:** a valid account without the staff flag sees "The username or password is invalid." and stays signed out. The check runs only in the browser.

## Dialogs and sheets

None.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/how-the-apps-work/screens/staff/sign-in.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
