# Login

### 📘 Overview

The **Login** screen enables users to access the DIGIT HCM app by entering their User ID and password. It also provides a **Forgot Password** option that informs users to contact their administrator since the app doesn’t handle password resets directly.

***

### 🔁 Workflow Details

#### Entry Point

* Users are redirected to the login screen immediately after selecting their preferred language.

<div align="left"><figure><img src="/files/JaPOJAmdVihwqDkrSpwc" alt="" width="207"><figcaption></figcaption></figure></div>

#### User Actions

* **Input Credentials**: User enters **User ID** and **Password**.
* **Login**: Clicks **"Log In"** to authenticate with the backend.
* **Forgot Password**: Clicks the **"Forgot Password"** button (no password reset performed within the app; displays informational dialogue).

***

### ⚙️ Technical Implementation

#### UI Components

* **Login Screen**: Defined in\
  `health_campaign_field_worker_app/lib/pages/login.dart`  \
  Login Page Location: [login.dart](https://github.com/egovernments/health-campaign-field-worker-app/blob/master/apps/health_campaign_field_worker_app/lib/pages/login.dart)
* **Widgets Used**:
  * **DigitTextFormField**: Input fields for user ID and password:  [digit\_text\_form\_input.dar](https://github.com/egovernments/DIGIT-UI-LIBRARIES/blob/master/flutter/digit-ui-components/digit_components/lib/widgets/atoms/digit_text_form_input.dart)
  * **DigitElevatedButton**: Login button component: [digit\_button.dart](https://github.com/egovernments/DIGIT-UI-LIBRARIES/blob/master/flutter/digit-ui-components/digit_components/lib/widgets/atoms/digit_button.dart)
  * **DigitToaster (SnackBar)**: Notification for login success, failure, or errors: [digit\_toast.dart](https://github.com/egovernments/DIGIT-UI-LIBRARIES/blob/master/flutter/digit-ui-components/digit_components/lib/widgets/atoms/digit_toast.dart)

#### Dialogue Integration

* The “Forgot Password” button triggers a **DigitDialog**, displaying a message prompting users to contact their administrator.

***

### 🔐 API Role–Action Mapping

| Action               | API Endpoint                       | Description                                                                               |
| -------------------- | ---------------------------------- | ----------------------------------------------------------------------------------------- |
| Login Authentication | `POST /auth/login` (or equivalent) | Sends credentials (`userID`, `password`) to authenticate user and return a session token. |
| Forgot Password      | –                                  | No backend call; purely client‑side informational dialog                                  |

* **Login Payload Example**:

  ```json
  {
    "RequestInfo": { "authToken": "" },
    "User": {
      "userId": "string",
      "password": "string"
    }
  }
  ```
* **Login Response**: Returns a user token and possibly user role/context data to establish a session and navigation flow.
* **Access Management**: The returned authentication token governs user access across the application.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digit.org/health/deploy/configuration/hcm-ui-configuration/login.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
