system użytkowników
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user