system użytkowników

This commit is contained in:
2026-10-03 19:31:38 +02:00
parent b09dde607a
commit d603d8d574
12 changed files with 314 additions and 3 deletions
+34
View File
@@ -46,6 +46,40 @@ alembic upgrade head
python seed.py
```
## Users
There is no public registration. All accounts are created by an administrator.
Pages (`/`, `/home`, `/sensors`, `/api/docs`) and `GET /api/*` require login.
`POST /api/*` stays open so devices can push data without a browser session.
Set a secret key for sessions (required in production):
```bash
export SECRET_KEY='long-random-value'
```
### First admin
The database starts with an empty `user` table. Create the first admin
with the CLI command (flags, env vars, or interactive prompts):
```bash
# Run database migrations first
alembic upgrade head
# Option 1: flags
flask --app app create-admin --username admin --password 'sekret'
# Option 2: environment variables (e.g. on first deploy)
ADMIN_USERNAME=admin ADMIN_PASSWORD=sekret flask --app app create-admin
# Option 3: interactive (asks for username/password)
flask --app app create-admin
```
Running `create-admin` for an existing username resets its password and
grants `is_admin=True`. After that log in at `/login` — you land on `/home`.
## Running
### Development