# Users & Roles

## User Types

| Type | `tenant_id` | Description |
|---|---|---|
| Platform user | `null` | Super-admin; can view all tenants |
| Tenant user | `{tenant_id}` | Belongs to one ISP; sees only their tenant |

---

## Roles

### super-admin
- Bypasses all permission checks (`Gate::before()`)
- Can manage all tenants, users, and platform settings
- Assigned with no team (platform-level)

### admin
- Full access within their tenant
- Can manage users, roles, packages, villages, billing config

### manager
- Can manage customers, packages, bills, payments
- Cannot manage users or system configuration

### billing-staff
- Can create and edit bills and record payments
- Cannot manage customers or configuration

### support-staff
- View-only access to customers and bills
- Cannot modify any data

### viewer
- Read-only dashboard and report access

---

## Creating a User

1. Go to **Users → Add User**
2. Enter full name, username, email, contact, CNIC
3. Assign a role
4. Set status to `active`

Login is possible with **email**, **username**, or **contact number**.

---

## Permissions List

Permissions follow the pattern `{action}.{resource}`:

```
view.tenant      manage.tenant
view.user        create.user      edit.user       delete.user
view.customer    create.customer  edit.customer   delete.customer   import.customer
view.package     create.package   edit.package    delete.package
view.village     create.village   edit.village    delete.village
view.bill        create.bill      edit.bill       delete.bill       generate.bill
view.payment     create.payment   edit.payment    delete.payment
view.report      export.report
view.configuration  manage.configuration
view.log
```

---

## Session Logs

All login and logout events are recorded in `session_logs` with IP address and
user agent. Admins can view login history under **Reports → User Logs**.
